Regular Expression Tester

Type a pattern, tick the flags, and see every match highlighted in your test string with its index, capture groups and a live preview of .replace.

Runs in your browser. Your image is never uploaded.

How to use Regex Tester — Test Regular Expressions Online Free

  1. 1Type your regular expression and pick the flags you need.
  2. 2Paste the text to test against — matches are highlighted as you type.
  3. 3Check the match list for capture groups, or use the replace field to preview a substitution.

About Regex Tester

A regex is faster to write than to read, which is why a tester earns its place. Paste the text you actually have, build the pattern a piece at a time, and the highlighting tells you immediately whether you matched what you meant to — or whether a greedy quantifier quietly swallowed half the line. Every match is listed with its start and end offset, so when a pattern matches the right characters in the wrong place, you can see it rather than guess.

Capture groups are where most of the real work happens, and they get their own column. Numbered groups appear as $1, $2 and so on; named groups appear as $<name>, which is what makes a pattern self-documenting six months later. The Replace tab then runs the same pattern through String.replace so you can see the output before you commit to it — the date example turns 2024-03-09 into 09/03/2024 with $<day>/$<month>/$<year>, and swapping two fields around becomes a one-line change instead of a loop. A group that matched nothing is labelled differently from one that matched an empty string, because in a replacement those two behave the same way but in your code they do not.

Two honest limitations are worth stating. First, this is JavaScript regex: the browser compiles your pattern, so anything ECMAScript lacks — atomic groups, possessive quantifiers, recursion — will not work here and, more usefully, anything that works here will work in your JavaScript. Second, the ready-made patterns are pragmatic, not authoritative. The email pattern catches ordinary addresses including multi-label domains like example.co.in, but no regex validates an address to the letter of RFC 5322, and the only real proof an address works is a delivered message. The phone pattern matches a run of digits and separators, which is the right trade-off for finding numbers in text but will also match things that are not phone numbers. Use them as a starting point you edit, which is exactly what the one-click buttons are for.

Frequently asked questions

Which flavour of regex does this tester use?
ECMAScript — the regex engine built into your browser, the same one your JavaScript or TypeScript will use. That means named groups (?<name>…), lookbehind (?<=…), and \p{…} Unicode property escapes with the u flag all work in current browsers. It also means the things PCRE, Python and .NET add are not available: no atomic groups, no possessive quantifiers like a++, no recursion, and no \A, \z or \h. Use ^, $ and \b instead. If you are writing a pattern for a PHP, Python or Java codebase, test it in that language before shipping it — most simple patterns are portable, but the edges are not.
What do the g, i, m, s, u and y flags do?
g (global) finds every match instead of stopping at the first. i ignores upper and lower case. m (multiline) makes ^ and $ match at each line break rather than only at the ends of the whole string. s (dotAll) lets the dot match newline characters too. u (unicode) treats the pattern as code points and enables \u{…} and \p{…}. y (sticky) matches only at the current position without scanning forward. The newer d and v flags are not offered here — d only adds group positions, and this tool already reports the start and end index of every match.
Why does it only find the first match?
Because the g flag is off. Without g, a JavaScript regex reports one match and stops, which is exactly how RegExp.exec and String.match behave in real code — so this reflects what your program would do. Tick the g checkbox and every match is highlighted and listed. The same rule applies on the Replace tab: without g, only the first match is replaced, and the tool says so underneath the result.
Is there a limit on how many matches it will show?
Yes, two deliberate ones. The match loop stops after 2,000 matches and tells you it did, and the match table lists the first 200 rows with a count of the rest — both to keep the page responsive on a long test string. Zero-length matches, the kind \b or a* produce, are handled specially: the loop steps past them by hand so they cannot loop forever, and they appear as a thin marker in the highlighted text. One thing no cap can protect you from is catastrophic backtracking: a pattern like (a+)+$ against a long run of a's can stall inside a single engine call that JavaScript cannot interrupt. If the page freezes on a pattern, that is almost always why.
How do I use capture groups in the replacement?
$& inserts the whole match, $1 through $9 (and beyond) insert numbered capture groups, $<name> inserts a named group, and $$ inserts a literal dollar sign. The built-in date example shows the useful case: matching (?<year>…)-(?<month>…)-(?<day>…) and replacing with $<day>/$<month>/$<year> rewrites 2024-03-09 as 09/03/2024. A group that did not take part in the match inserts nothing, and the match list marks it "did not participate" so you can tell that apart from a group that matched an empty string.
Does my pattern or test text leave my browser?
No. The whole tool is JavaScript running on your device — your pattern is compiled by the browser and your test string is never sent anywhere, so you can safely paste log lines, customer records or anything else confidential. Load the page once and it keeps working with the network switched off. There is no sign-up and no limit on how many times you run it.