19 chars · 1 line
5 chars · 1 line
19 chars · 1 line
5 chars · 1 line
Regex matching guide
Enter a JavaScript regular expression and sample text above, then choose Match All to enumerate each occurrence. The output includes matched text, zero-based indexes, numbered captures, and named groups when the pattern defines them. This tool is free to use. No account or payment is required.
Last updated
Each result reports the full matched substring and the zero-based character index where it begins. That makes it easier to compare regex behavior with parser offsets, editor positions, and source text.
Numbered groups are returned in capture order and unmatched optional groups appear as null. Named groups are exposed as a separate object so extraction code can be checked against the labels used by the pattern.
Match All adds a global scan when the user omitted g, but the stored flag string is left unchanged so Test and Replace modes still follow the flags you entered.
Patterns built from lookarounds or optional constructs can match an empty string. The matcher advances after a zero-length match so scanning cannot become stuck at the same position in a manual exec loop.
A pattern extracts level and numeric code from two log tokens, returning each source index and both capture groups.
/(ERROR|WARN):(\d+)/g
ERROR:42 WARN:7[
{ "match": "ERROR:42", "index": 0, "captures": ["ERROR", "42"] },
{ "match": "WARN:7", "index": 9, "captures": ["WARN", "7"] }
]Common questions
It returns the zero-based JavaScript string index where each full match begins.
Match All adds a global flag only for the scan so every occurrence can still be listed.
Yes. An unmatched numbered capture is represented as null so the capture positions remain stable.
Debugging a specific Regex issue? Browse Regex troubleshooting.