Regex Tester
Test regular expressions with live match highlighting, capture groups and replacement preview. Safe from runaway patterns, private in your browser.
Runs in your browser. Nothing is uploaded.
About the Regex Tester
Regular expressions (regex) are patterns for finding and replacing text: validating email addresses, extracting dates from logs, cleaning data, and search-and-replace in code editors. They're powerful but easy to get subtly wrong.
This tester highlights every match as you type, lists capture groups (numbered and named) with their positions, and previews replacements. It uses your browser's JavaScript regex engine, the same one used by Node.js and front-end code.
Patterns run in a separate background worker with a time limit, so a pattern that would hang (catastrophic backtracking) is stopped instead of freezing your tab.
How to use it
- Type your pattern between the slashes. There's no need to escape the slashes themselves.
- Tick the flags you need: g (all matches), i (ignore case), m (multiline), s (dot matches newlines), u (Unicode).
- Paste sample text into “Test text”. Matches are highlighted and listed with their groups.
- Tick “Preview a replacement” to try a replacement string using $1, $2 or $<name>.
Examples
Email-like strings
\b[\w.+-]+@[\w-]+\.[\w.]+\b with the g flag finds [email protected] and [email protected] in a paragraph.
Reformat dates
Pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 turns 2026-11-16 into 16/11/2026.
Named groups
(?<key>\w+)=(?<value>\w+) on a=1&b=2 shows key and value for each pair.
Unicode letters
With the u flag, \p{L}+ matches words in any script, such as “naïve”, “東京” and “Москва”.
Limitations
- This is the JavaScript (ECMAScript) regex flavour. Some features of PCRE, Python or .NET regex, such as possessive quantifiers, (?i) inline flags or conditionals, aren't supported.
- The match list shows the first 1,000 matches.
- Patterns that take longer than about 1.5 seconds are stopped and reported.
- Safari has its own safety limit: it gives up on extremely slow patterns by itself and reports no match, so you may see “No matches” there instead of the time-limit message.
Frequently asked questions
Why does my pattern only find one match?
Without the g (global) flag, JavaScript stops after the first match. Tick g to find all of them.
What is catastrophic backtracking?
Patterns with nested quantifiers, like (a+)+$, can take exponentially long on text that almost matches. The tester stops such patterns after a time limit; rewrite them to avoid ambiguous repetition.
How do I match a literal dot or bracket?
Escape it with a backslash: \. matches a dot, \( a parenthesis, and \\ a backslash.
Will my pattern work in Python or Java?
Most common syntax (character classes, groups, quantifiers, anchors) is shared, but details differ between engines. Test in the target language for anything advanced.