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.
Pattern
JavaScript RegExpERROR
Test string
paste anythingMatches
first 200 drawn- match
- $1
- $2
- $3
- $4
Match table
index · match · $1Twelve patterns you keep retyping
one tap · pattern + flags + sampleEach 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 promised01The 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.
| Flag | What it changes |
|---|---|
| g | every match, not the first |
| i | case-insensitive |
| m | ^ and $ per line |
| s | . also matches a newline |
| u | full 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.