RegexLab · match · group · replace · zero upload

Every match, every group.
In colour, as you type.
Nothing leaves the tab.

Write a pattern, paste the text, and watch each match light up with its capture groups in their own colour — plus the index and $1 table, a replace preview that rewrites itself on every keystroke, and a guard that stops a runaway pattern before it freezes the tab.

0 bytes uploaded 0 external requests flags g · i · m · s · u ReDoS guard · 1.2 s

Pattern

JavaScript RegExp
gi

Test string

paste anything

Matches

first 200 drawn
  • match
  • $1
  • $2
  • $3
  • $4
0matches
0groups
0characters
0ms

Match table

index · match · $1

Twelve patterns you keep retyping

one tap · pattern + flags + sample

Each preset loads the pattern, the right flags and a sample text so the result appears immediately. Nothing is locked — edit the pattern after loading it, and the table follows.

How the guard works

measured, not promised

01The match runs in a worker

Every keystroke is sent to a worker built from a string inside this page, so the pattern runs on a second thread with its own time budget. If the run has not answered in 1.2 seconds — the signature of catastrophic backtracking, like (a+)+$ against a long run of a — the worker is terminated and the page reports a stop. The tab stays responsive and your text is untouched.

02Group offsets come from the d flag

Colouring a capture group needs its start and end, not just its value. The d flag (added internally, never shown) makes exec return indices, so $1 can be painted over exactly the characters it captured. Where a browser has no d flag, the group colour falls back to the match colour and the table still carries every value.

FlagWhat it changes
gevery match, not the first
icase-insensitive
m^ and $ per line
s. also matches a newline
ufull Unicode mode

03Limits, stated plainly

The text is tested up to 100,000 characters; the first 500 matches are collected and the first 200 are drawn. Beyond that the table says so instead of pretending the list is complete. Zero-length matches (^, \b) are advanced by one character so the loop always ends — those are the runs a naive tester hangs on.

Questions

flavour · guard · limits
Which regex flavour is this?
Your browser's own JavaScript RegExp — the same engine your code will use, with named groups, lookbehind and unicode property escapes where the browser has them. Nothing is translated to another flavour, so a pattern that passes here is a pattern that runs there.
Why did it stop with “pattern too expensive”?
Two nested quantifiers around the same characters — (a+)+, (.*)* — make the engine try exponentially many splits. The guard cut the run at 1.2 s rather than let the tab die. Rewrite it with a possessive-style shape such as [^,]* or an atomic alternative, and it will finish in microseconds.
Does the replace preview change the text?
No. The replacement is computed on a copy and shown in its own box; the test string stays exactly as you typed it. Copy the result or save it as .txt when it is right — the text you pasted is never edited in place.
Where does my text go?
Nowhere. There is no server to send it to, no analytics and no storage; the pattern and text live in this tab and the worker, and disappear when you close it. The footer counts external requests and it stays at 0.