Regular Expression Tester
Test a pattern against text as you type, with matches highlighted, capture groups listed and a live replace preview.
Flags, and the one that surprises people
g finds every match rather than the first, i ignores case, m makes ^ and $ match at line boundaries instead of only at the ends of the string, and s lets . match newlines. The one that catches people out is g on a reused RegExp object: it carries a lastIndex between calls, so the same test alternates between true and false. Build a fresh regex or reset lastIndex.
Catastrophic backtracking
Nested quantifiers over overlapping character classes — the classic being (a+)+b — can take exponential time on input that nearly matches. On a server handling user input that is a denial-of-service vector, and it has taken down large sites. If a pattern hangs this page on a long test string, that is the bug announcing itself early, which is the best place to find it.
Your patterns and test data stay in the page; the regex engine is the browser's own.
Common questions
Why does my /g regex return alternating results?
A reused RegExp with the g flag keeps a lastIndex between calls. Create a new regex each time, or reset lastIndex to 0.
What is catastrophic backtracking?
Nested quantifiers over overlapping classes can take exponential time on near-matching input. On a server processing user input it becomes a denial-of-service risk.
Which flavour of regex is this?
JavaScript's, since it uses the browser's own engine. Most patterns are portable, but lookbehind and named groups differ between languages.