SHEET 04tools/regex-lab/ REVISED
Regex lab
Test JavaScript regular expressions against your own text. See every match and capture group, with a plain-English note on each flag.
- g: find every match
3 matches.
Highlighted text
Shipped 2026-11, patched 2027-03, retired 2029-12.
Matches
| # | At | Match | Groups |
|---|---|---|---|
| 1 | 8 | 2026-11 | $1: 2026$2: 11year: 2026 |
| 2 | 25 | 2027-03 | $1: 2027$2: 03year: 2027 |
| 3 | 42 | 2029-12 | $1: 2029$2: 12year: 2029 |
Regex lab is a scratchpad for JavaScript regular expressions. Type a pattern and some test text, and it highlights every match and lists its capture groups as you type.
How it works
The pattern runs in your browser on the same JavaScript regex engine your code uses, inside a Web Worker. If a pattern runs longer than a second, the worker is stopped so a runaway pattern can't freeze the page. Results list up to 1,000 matches with their positions, numbered groups and named groups.
Questions
- Which regex flavour does it use?
- JavaScript (ECMAScript), as your browser implements it. Features from other engines, such as possessive quantifiers in PCRE, won't work here.
- Which flags can I use?
- d, g, i, m, s, u, v and y. The lab always looks for every match, so g is on even if you leave it out.
- Why did my pattern time out?
- Usually catastrophic backtracking. Nested quantifiers like (a+)+ can take exponential time on some inputs. Remove the nesting or make the inner part more specific.