Regex tester
Live matching, flags, and every capture group listed
Enter the pattern without surrounding / delimiters, add flags and supply text. Result offsets start at zero; timed-out calculations are stopped.
Example
Input
Pattern: (cat|dog) Flags: g Text: cat and dog
Example result
#0 "cat" $1 = "cat" #8 "dog" $1 = "dog"
Offsets start at zero. Do not include surrounding / delimiters in the pattern field.
Technical details & limits
Offsets count JavaScript UTF-16 code units. g finds all matches, i ignores case, m changes line anchors, s lets dot match newlines and u enables Unicode mode. Matching runs in a separate worker with a timeout to limit page blocking from backtracking; output is capped at 5000 matches.
About this tool
Test patterns with the browser's JavaScript regex engine. Inspect match offsets, complete matches and capture groups with g, i, m, s, u and y flags.
Use cases
- Sanity-check a regex before dropping it into a log-parsing script.
- Debug why an “almost working” regex fails on a specific line.
- Pull the values of named capture groups out to inspect structure.
How to use
- Enter the expression in Pattern without surrounding / delimiters.
- Enter flags in Flags: g (global), i (case-insensitive), m (multiline), s (dot-all), u (Unicode) or y (sticky). Use each at most once.
- Paste the target text in Text. Editing any field reruns the match.
Notes
Uses JavaScript’s RegExp engine, which differs in some corners from PCRE / Go / Java (backtracking, atomic groups, conditionals). Ultimately test in your target language.
FAQ
- Why the 5000-match cap?
- To keep the browser responsive under runaway patterns. Trim the text or refine the pattern if you hit it.
- Why is the g flag not matching all occurrences?
- Check that `g` is actually in your flags. If the pattern can match an empty string, the tool steps forward automatically to avoid an infinite loop — the same applies in real code.
- How do I test named capture groups?
- Use `(?<name>...)`. The tool lists matches by `<name>` alongside numbered groups.
- Why do PHP or Python produce different matches?
- Regex engines differ in Unicode behavior, lookbehind and named-group syntax. These results describe your browser's JavaScript implementation; retest in the target language.
- Why can results differ from PHP or Python?
- This uses the browser's JavaScript regex engine. Other languages can differ in syntax, Unicode behavior and flags; a match here does not validate every engine.
Related tools