Regex Tester and Explainer
Test a JavaScript regular expression: highlighted matches, capture groups, replace, split and a plain-English explanation.
How it works
Type a pattern, pick the flags and paste your text. Every match is highlighted, and a table lists each match with its position and capture groups (named groups show their name). Pick Replace to preview a substitution using $1, $2 or $<name>, or Split to cut the text at each match.
The explainer under the results reads your pattern one piece at a time in plain words. This tool uses the regex engine of your own browser (the JavaScript flavour), the same one used in Node.js and web pages.
- Pick a ready pattern or type your own.
- Set flags: g finds all matches, i ignores case, m makes ^ and $ work per line, s lets . match line breaks, u turns on Unicode.
- Paste the text to test against.
- Read the matches, groups and the explanation.
Worked example
Pattern (?<day>\d{2})/(?<month>\d{2})/(?<year>\d{4}) on "Exam on 05/12/2026" gives one match at position 8 with day=05, month=12, year=2026. In Replace mode with $<year>-$<month>-$<day> it becomes "Exam on 2026-12-05".
Good to know
- JavaScript regex is not the same as Python, Java or PCRE. For example there is no (?i) inline flag and no possessive quantifiers.
- A pattern like (a+)+ can freeze a browser on some text (catastrophic backtracking). The tool warns about shapes that look risky.
- To match a special character literally, put a backslash before it: \. \( \? \$.
- Format-only presets (PAN, GSTIN, IFSC) check the shape, not whether the number really exists.
Common questions
- What do the flags mean?
- g all matches, i ignore case, m ^ and $ match at every line, s dot matches line breaks, u full Unicode, y sticky (match only at the current position), d also report indices.
- Why do I get only one match?
- Without the g flag a regex stops after the first match.
- What is a capture group?
- Anything in ( ). The text it matched is saved and can be reused in a replacement as $1, $2, or by name as $<name>.
- Why does my pattern work here but not in Python or Java?
- Each language has small differences. Check its own documentation for named groups and lookbehind.
- What is the difference between greedy and lazy?
- Greedy (.*) matches as much as it can, lazy (.*?) as little as it can. On <b>a</b><b>b</b> the pattern <b>.*</b> takes everything but <b>.*?</b> takes one tag pair.
More in Developer.
See the ASCII code of every character in decimal, hex, binary and octal, or turn codes back into text.
OPEN →Axios Request GeneratorFill in a method, URL, headers and body and get a ready Axios Request snippet to copy.
OPEN →Base32 Encoder and DecoderEncode text to Base32 (RFC 4648) or decode it, as used in 2FA secrets.
OPEN →