Developer & Tech
Regex Tester
Enter your details
Runs in your browser
How to use it
Using the regex tester
- 01
Write your pattern
Without delimiters or slashes; just the expression itself.
- 02
Set flags
g for all matches, i for case-insensitivity, m for multiline anchors; duplicates are cleaned automatically.
- 03
Inspect matches and groups
Each row shows the matched text, its index and any capture-group contents.
Good to know
Why native-engine testing matters
Regex dialects differ subtly: JavaScript supports lookahead everywhere but lookbehind only in modern engines; POSIX classes like [[:alpha:]] fail entirely. Testing against the actual runtime regex engine eliminates the entire class of works-in-my-tool-but-not-in-prod surprises.
Reading capture groups
- $1 is the first parenthesized group, left to right
- Non-participating groups show as empty/undefined
- Named groups (?<year>…) work and appear positionally here
- Non-capturing (?:…) groups group without consuming a slot
How it's calculated
The math behind this calculator
matches = testString.matchAll(new RegExp(pattern, flags)); engine-native semanticsYour pattern and flags build a native RegExp, so results match exactly what production JavaScript will do; including lookaheads, named groups and lazy quantifiers. Invalid patterns surface the engine’s own syntax error rather than a generic failure.
Global iteration collects every match with its index; capture groups list for the displayed matches. Duplicate flags are de-duplicated silently, analysis caps at ten thousand characters as a catastrophic-backtracking guard, and display caps at twenty rows.
Assumptions & limitations
- JavaScript (ECMA-262) flavor; differs from PCRE/Python in escapes and lookbehind support.
- Analysis truncates beyond 10,000 characters.
- At most 500 matches iterate per run as a safety bound.
Worked example
Counting the vowel “a” across “banana” with global flags finds exactly three matches; the quickest possible sanity check that flags and counting behave.
FAQ
Frequently asked questions
- Do I include the /slashes/ around my pattern?
- No; enter just the expression. Slashes are literal characters in this context and would break matching.
- Why does my huge document get truncated?
- Analysis stops at 10,000 characters to guard against catastrophic backtracking freezing your browser. The note row tells you when truncation happened.
- My pattern is valid elsewhere but rejected here?
- You are probably using another flavor’s syntax (lookbehind on an old browser, possessive quantifiers, \p classes). This tool reports the exact JS engine error.
- Does it show overlapping matches?
- No; JavaScript matching consumes input as it goes, so consecutive matches never overlap, mirroring real replace() behavior.
Keep exploring