← All tools/Minifiers/Code/Regex Tester
Regex Tester
Try a regular expression against sample text and see every match, its position and its capture groups — live, in your browser.
Use $1, $2… to insert capture groups, and $& for the whole match.
Matches found
2 matches · 16 of 25 characters matched
Highlighted text
Replacement preview
How it works
JavaScript RegExp: new RegExp(pattern, flags) Flags: g = all matches · i = ignore case · m = ^ and $ match line starts and ends s = . matches newlines · u = full Unicode matching Match index = position of the first character, counting from 0. Replacement: $1, $2… = capture groups · $& = whole match · $$ = a literal $.
Worked example — pattern \d{3}-\d{4} against “Call 555-1234 or 555-9876”: the engine finds 2 matches, “555-1234” at index 5 and “555-9876” at index 17, covering 16 of the 25 characters. With the replacement XXX-XXXX the preview reads “Call XXX-XXXX or XXX-XXXX”.
Patterns run on the browser’s JavaScript RegExp engine, so what works here works in JavaScript and Node.js code. An invalid pattern shows its error message instead of a result.
Frequently asked questions
Why does my pattern say “Invalid pattern”?
The pattern has a syntax error — usually an unbalanced bracket or parenthesis, a stray backslash at the end, or a bad quantifier like **. Fix the highlighted part and the error message names the problem: for example, “[a-z” is missing its closing bracket.
What is the difference between the g flag and no flag?
Without g the tester finds only the first match; with g it finds every match in the text. Turn g on when you want a full count and a full highlight, and off when you only care about the first occurrence.
How do capture groups work?
Parentheses mark a group: in (\d{3})-(\d{4}), group 1 is the three digits before the hyphen and group 2 is the four after it. The match list shows each group, and in the replacement box $1 inserts group 1 and $2 inserts group 2.
Does this tester use JavaScript or Python regex?
JavaScript — it runs the same RegExp engine your browser and Node.js use, so a pattern that works here works in your JavaScript code. Python’s re module is close but not identical: for example, Python uses \Z where JavaScript uses $ with the m flag off.
Is my test text sent anywhere?
No. Everything runs in your browser — the pattern, the text and the matches never leave the page, so you can safely test patterns against real data.
Tell us what you think
Loving this tool, or stuck on something? Tell us — it takes a minute.
We’ll only use your name and email to reply if needed. The tool and page are filled in for you.