JavaScript regex tester
Test a JavaScript regular expression and see every match, group and replacement.
Runs in your browser. Your input is not uploaded.
Loading the tool…
What it does
This runs your pattern with the browser’s own RegExp, so the result is exactly what JavaScript will do. It is not PCRE, Python or Go syntax: lookbehind and named groups work, but possessive quantifiers and (?i) inline flags do not.
Every match is listed with its position and capture groups, and you can preview String.replace with $1 or $<name> references.
How to use it
- Enter the pattern without slashes and tick the flags.
- Paste the test text.
- Read the matches and groups, and try a replacement if you need one.
Example: Pattern (\d{4})-(\d{2}) with flag g
Input
Due 2026-11 and 2027-01
Output
Match 1: 2026-11 (groups: 2026, 11) Match 2: 2027-01 (groups: 2027, 01)
Things to watch for
- Without the
gflag only the first match is found. - Nested quantifiers such as
(a+)+can take exponential time on some input. The tester stops listing after 1,000 matches but cannot interrupt a single slow match. - In a JavaScript string literal you need to double backslashes:
/\d/becomesnew RegExp("\\d").
Questions
- Which flags are supported?
gglobal,iignore case,mmultiline anchors (^and$match at each line),sdot matches new lines,uUnicode andysticky.- Is this the same as PCRE or Python?
- No. Most everyday syntax is shared, but test in the target language before relying on edge cases.
- How do I match a literal dot or bracket?
- Escape it with a backslash:
\.or\[. The string escape tool has a Regex option that escapes a whole string. - How do named groups work?
- Write
(?<year>\d{4}). The group appears by name in the results, and$<year>refers to it in a replacement.