GitGudgit gud
gitgudRun an audit
‹ all tools
Inspectgitgud / tools

Regex Tester

Live matches, capture groups and highlighting against your test string.

Runs entirely in your browser — nothing you paste is uploaded.

About Regex Tester

Write a pattern, paste a test string, see what matches — highlighted in place, and listed with every capture group and its index. That immediate feedback is the whole point: regular expressions are much easier to build incrementally against real input than to write correctly in one pass.

All six JavaScript flags are toggleable. `g` finds every match instead of the first. `i` is case-insensitive. `m` makes `^` and `$` match at line boundaries rather than only at the ends of the string. `s` lets `.` match newlines. `u` enables full Unicode mode, which is what makes `\p{L}` and astral-plane characters behave. `y` anchors each match to `lastIndex`.

Named capture groups — `(?<year>\d{4})` — are shown by name, which is worth using in anything you'll read again. So is the distinction between a capturing group `(...)` and a non-capturing one `(?:...)`: the second groups for alternation without adding to your results.

This is JavaScript's regex engine, which matters because engines differ. Lookbehind is supported in modern JavaScript but not in Safari before 16.4, `\d` matches only ASCII digits unless you're in Unicode mode, and there is no recursion or possessive quantifier the way PCRE has. A pattern that works here will work in Node and in a browser; it may not work in Python, Go or grep.

Frequently asked

›Why does my regex only find the first match?

The `g` flag isn't set. Without it, `match` returns the first result with its capture groups; with it, it returns every match but no groups. `matchAll` with `g` gives you both, which is what this tool uses.

›How do I match across multiple lines?

Two different flags, commonly confused. `m` (multiline) changes what `^` and `$` mean, anchoring them to line boundaries. `s` (dotAll) changes what `.` matches, letting it cross newlines. Matching a block that spans lines usually needs `s`, not `m`.

›Should I use a regex to parse HTML or JSON?

No. Both are recursively nested and regular expressions cannot express arbitrary nesting. Use a parser. A regex is right for extracting a well-defined token from a flat string — a date, an ID, a log field.

›What is catastrophic backtracking?

A pattern with nested quantifiers over overlapping alternatives — `(a+)+b` is the textbook case — can take exponential time on input that nearly matches. If a pattern hangs the tool, that's what happened. Anchor your pattern and avoid nesting a quantifier inside another.

›Are my patterns and test text sent anywhere?

No. Everything runs in your browser against your own input.

Related tools