Regex tester
Type a pattern and watch it match live: highlighted text, capture groups spelled out, a replace preview and a shareable link that never touches a server.
Guide
How to use it
- Type the pattern without surrounding slashes; toggle flags beneath it (hover each for what it does).
- Paste test text. Matches highlight as you type, and the list shows each match with its groups.
- Add a replacement with $1-style references to preview a rewrite, then copy the result.
- Copy shareable link packs pattern, flags and text into the URL fragment for a colleague.
- Blank on syntax? The cheat sheet and common patterns pages feed straight into this tester.
Examples
Worked examples
The preloaded pattern grabs the two real addresses in the sample and correctly skips sam@localhost, no dot in the domain.
Pattern (\d\d)/(\d\d)/(\d{4}), replacement $3-$2-$1: UK dates become ISO dates across a whole file in the replace preview.
\b(\w+)\s+\1\b with the i flag catches "the the" and "is is", the classic proofreading slip that eyes skate over.
Method
How it works
Your pattern is compiled by the browser's own JavaScript regex engine, so what matches here matches in your code. Matches are found with exec in a loop (capped at 2,000, with zero-length matches stepped over rather than spinning), highlighted in place and listed with their numbered groups. The replace preview is a straight String.replace with your pattern and replacement.
Shared links keep everything in the URL fragment, which browsers never transmit, so even the sharing is private.
FAQ
Frequently asked questions
Which regex flavour does this use?
JavaScript's, the flavour of the browser you are in. It is close to PCRE for everyday patterns; the differences show in exotic features like lookbehind support and possessive quantifiers.
What do the flags mean?
g finds all matches instead of the first, i ignores case, m makes ^ and $ work per line, s lets the dot match newlines and u enables full unicode handling. Hover each flag for a reminder.
Why does my pattern match too much?
Usually a greedy quantifier: .* grabs as much as possible. Add ? for the lazy version (.*?) or, better, match what you mean, like [^"]* for everything up to a quote.
How do capture groups work in replace?
Parentheses capture parts of each match; $1, $2 and so on reinsert them in the replacement. Swapping day and month in dates is the classic use.
Is my test text sent anywhere?
No, matching runs in your browser. Even the share link keeps everything in the URL fragment, the part after #, which browsers never send to any server.
Why does an empty match show a caret mark?
Patterns like a* can match zero characters at a position. The tester marks the spot rather than looping forever, which is a hint the pattern needs anchoring.
More tools