Regex Tester
Write a regular expression, paste some text and see every match highlighted as you type, with capture groups listed and a live preview of replacements.
- Runs in your browser
- No sign-up
- Free to use
| # | Position | Match | Groups |
|---|
How to use Regex Tester
- Enter your pattern in the expression field, without the surrounding slashes.
- Tick the flags you need, such as g for all matches or i to ignore case.
- Paste or type the text to test. Matches are highlighted immediately and listed with their groups.
- Optionally enter a replacement string to preview the result of a replace operation.
Regex Tester features
Live highlighting
Matches are marked in the test text as you edit the pattern or the text.
Capture group details
Each match shows its position and the contents of numbered and named groups.
Replace preview
See the output of a replacement, including $1 and $<name> references.
All JavaScript flags
Global, ignore case, multiline, dotAll, Unicode and sticky.
Runaway pattern protection
Expressions that take too long are stopped and reported instead of freezing the tab.
Clear syntax errors
Invalid patterns show the engine's error message straight away.
When to use Regex Tester
- Developing a validation pattern for emails, phone numbers or postcodes.
- Working out a find-and-replace for a code editor or script.
- Extracting fields from log lines.
- Learning how quantifiers, groups and lookarounds behave.
Regex Tester FAQ
Which regex flavour does this use?
The JavaScript (ECMAScript) engine built into your browser. Most syntax is shared with PCRE, Python and .NET, but there are differences: for example, JavaScript has no possessive quantifiers or inline (?i) modifiers in older browsers.
What do the flags mean?
g finds all matches rather than the first. i ignores case. m makes ^ and $ match at line breaks. s lets the dot match line breaks. u enables full Unicode handling and \p{…} classes. y matches only at the current position.
Why did my pattern time out?
Some patterns, typically nested quantifiers such as (a+)+ applied to text that almost matches, cause exponential backtracking. The tester stops them after two seconds. Rewrite the pattern to avoid ambiguous repetition.
How do I reference groups in the replacement?
Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.
Is my test text sent anywhere?
No. Matching happens in your browser.
Getting regular expressions right
A regular expression describes a pattern of characters. The engine scans the text from left to right, trying at each position to match the pattern, and backtracks when a choice does not work out. Most surprises come from greediness: by default quantifiers such as * and + take as much as they can, so <.+> matches from the first < to the last > on a line. Adding a question mark makes a quantifier lazy.
Testing against realistic text is the fastest way to find such problems. Include examples that should match, examples that should not, and edge cases such as empty strings and unusual characters. Anchors (^ and $) are easy to forget in validation patterns, and without them a pattern matches anywhere inside a longer string.
Be cautious with user-supplied text and complex patterns on a server: an expression that backtracks exponentially can be used to stall a service. Keeping patterns simple and unambiguous protects against that.