Regex Tester
Test JavaScript regular expressions against sample text with live match highlighting and capture group details. Free browser-based regex tester.
Why the "g" flag is always on
Without the global flag, JavaScript's regex methods stop after the first match — useful sometimes, but not when the point of a tester is to see every place a pattern hits. This tool always adds "g" internally so the match count and highlight view reflect the full test string, even if you didn't type it yourself. Other flags you add — "i" for case-insensitive, "m" for multiline (^ and $ match at line boundaries, not just string boundaries), "s" for dotall (. matches newlines too), "u" for full unicode handling — combine with it normally.
Reading capture groups
Parentheses in a pattern create capture groups, and this tool lists what each one matched, in order, for every overall match found. A group can come back as `(undefined)` — that happens when it's inside an optional part of the pattern (like `(abc)?`) that simply didn't participate in that particular match, which is expected behavior, not an error. Named groups `(?<name>...)` work the same way as positional ones as far as JavaScript's match object is concerned; this tool currently lists them positionally.
A pattern that "hangs" almost never actually hangs
Certain regex patterns — typically ones with nested quantifiers like `(a+)+` — can exhibit catastrophic backtracking against specific input strings, where the number of match attempts grows exponentially with input length. If a pattern that worked fine on short test strings suddenly seems to freeze the tab on a longer one, that's very likely what's happening rather than a bug in the tool. The fix is almost always in the pattern itself: replace nested repetition with a single bounded quantifier, or make the ambiguous part of the pattern possessive/atomic where the regex flavor supports it.