Regex Tester
Test a regular expression against sample text and see matches highlighted live.
—
How this regex tester works
Type a pattern and some test text, and matches are highlighted live using JavaScript's native RegExp engine — the same engine your browser and Node.js use. Everything runs locally as you type; no pattern or test data is sent anywhere.
Why your regex might hang the page
Certain patterns, especially nested quantifiers like (a+)+ or (a|a)* matched against a long non-matching string, can trigger catastrophic backtracking — the engine tries an exponential number of ways to match before giving up. This can freeze a browser tab for seconds or longer on surprisingly short input. If a pattern that looks simple hangs the tester, that's usually the cause; rewriting the nested quantifier to avoid overlapping matches (or using a possessive/atomic group where supported) fixes it.
Flavor differences to watch for
JavaScript's regex flavor isn't identical to PCRE (used by PHP, and similar to what many online "regex101"-style tools default to) or Python's re module. Lookbehind assertions were only added to JS regex relatively recently and still have inconsistent support in some environments; named capture groups use slightly different syntax between flavors. If a pattern that supposedly "works everywhere" fails here, double-check it was tested against actual JavaScript, not another language's regex engine.
Frequently asked questions
Why does my regex freeze the tab?
Likely catastrophic backtracking from a pattern with nested or ambiguous quantifiers (e.g. (a+)+b) tested against text that doesn't quite match. Simplify the nested groups to remove the ambiguity.
Does this match Python or PCRE regex syntax exactly?
It uses JavaScript's native regex engine specifically, which is close to but not identical to PCRE or Python's re — particularly around lookbehind support and named groups.
How do I match across multiple lines?
Use the m (multiline) flag so ^ and $ match at line boundaries rather than only the start/end of the whole string, and the s (dotAll) flag if you need . to match newlines too.