Regex Tester
Test JavaScript regular expressions with live match highlighting, groups and a replace preview.
Enter a pattern and some text to test it.
Matches in your text
Replace preview
Match details
Try out a JavaScript regular expression on your own text
Regex Tester runs a regular expression against text you paste and shows the result as you type: how many matches there are, where they are in the text, what each capture group caught, and — if you want — what the text would look like after a replace.
It uses the JavaScript engine built into your browser, so the results are the same as String.match, RegExp.exec and String.replace in browser or Node.js code. Nothing you type is uploaded.
How to test a pattern
- Type the pattern without the surrounding slashes. If you paste a literal such as /\d+/gi, it is split into the pattern and its flags for you.
- Turn flags on or off: g finds every match, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u enables full Unicode handling and y (sticky) only matches where the previous match ended.
- Paste your test text. Matches are highlighted, and the list below shows each match’s position and groups.
- To preview a replacement, tick Preview a replacement and type the replacement text.
- If the pattern has a syntax error, the browser’s own error message appears under the field until you fix it.
What the highlights and match list show
- Match count: with the g flag every match is counted; without it only the first match is found, just like exec() and match() in JavaScript.
- Highlights: neighbouring matches alternate between two tints and are underlined. Empty (zero-length) matches, for example from \b or a*, show as a thin bar.
- Match details: each match lists its start and end index, the full match, numbered groups and named groups. A group that didn’t take part in the match shows as —.
- Long results: the first 1,000 matches are listed and highlighted; the count still includes every match.
Typical jobs for a regex tester
- Validating input: check a pattern for postcodes, order numbers or IDs against good and bad examples before putting it in a form.
- Extracting data from logs: use groups to pull dates, status codes or user IDs out of lines of text.
- Planning a search and replace: see the result of a replace on sample text before running it across a codebase.
Tips for reliable patterns
- Anchor patterns with ^ and $ when validating a whole value, or a partial match will slip through.
- Name groups with (?<name>…) so replacements can use $<name> instead of counting brackets.
- Avoid nested quantifiers such as (a+)+ or (.*)*: on text that almost matches they can take exponentially long. The tester stops any run after one second and tells you.
- To clean up text before matching it, the Text Cleaner removes extra spaces and blank lines; to compare text before and after a replace, use Text Compare.
JavaScript regex syntax and replacements
How JavaScript differs from PCRE and Python
Most everyday syntax is shared, and modern JavaScript supports lookbehind ((?<=…) and (?<!…)) and named groups. Some features found in PCRE (PHP, grep -P) or Python are missing: possessive quantifiers such as a++ and atomic groups (?>…) aren’t supported, nor are \A and \Z — use ^ and $ without the m flag instead. Named groups are written (?<name>…), not Python’s (?P<name>…), and a mode switch such as (?i) at the start of a pattern isn’t accepted, so use the flag checkboxes.
Replacement patterns
In the replacement, $1, $2 and so on insert numbered groups, $<name> inserts a named group, $& inserts the whole match and $$ writes a literal dollar sign. With the g flag every match is replaced; without it only the first one is, which is how String.replace behaves. An empty replacement shows the text with the matches removed.
Regex Tester: common questions
Why does my pattern find only one match?
The g (global) flag is off. Without it JavaScript stops after the first match, and the summary says so. Turn on g to find them all.
What does “This pattern took too long” mean?
The pattern ran for more than a second, usually because of catastrophic backtracking, where nested or overlapping quantifiers try a huge number of combinations. The run is stopped so the page stays usable; make the pattern more specific and it is tested again straight away.
Do I need to escape slashes?
No. The pattern is passed to new RegExp() without slashes, so / is an ordinary character. You only need \/ when writing a literal in source code.
Will a pattern that works here work in PHP or Python?
Often, but not always. The engine here is JavaScript’s, so check the differences above, especially named group syntax and features such as atomic groups.
Is my test text stored anywhere?
No. Matching runs in a background worker inside your browser tab, and closing the page discards everything. Other developer tools on Brisqnex work the same way.

