Regex Tester

Test regular expressions — matches highlighted, groups, replace

About Regex Tester

Regex Tester runs a pattern with JavaScript's own RegExp engine, the one built into your browser, on text you paste. Up to 5,000 matches are found and highlighted in the text, and the first 200 are listed with their start and end positions and the value of each numbered and named capture group. Checking Replace with previews the result of String.replace with $1, $<name>, $&, or $$. The search runs in a separate worker that is stopped after 2 seconds, so a pattern with catastrophic backtracking is reported instead of freezing the tab. Other flavors (PCRE, Python, .NET) are not available.

Example

Output of the page's own search code (the worker it runs), with the replacement option on.

Pattern, Flags, text, Replace with

Pattern: (?<year>\d{4})-(\d{2})
Flags: g
Text: Released 2024-03, updated 2025-11.
Replace with: $2/$<year>

Result

2 matches
#1  9–16   2024-03   $1: 2024  $2: 03  year: 2024
#2  26–33  2025-11   $1: 2025  $2: 11  year: 2025
Result of the replacement: Released 03/2024, updated 11/2025.

How to test a regular expression in JavaScript

  1. 1Type the pattern in "Pattern" without slashes, and the flags in "Flags" (g by default; d, i, m, s, u, v, and y are also accepted).
  2. 2Paste the text to search in the large box below.
  3. 3To try a substitution, check "Replace with" and type the replacement, for example $2/$<year>.
  4. 4Click "Test": matches are highlighted and listed with positions and groups, and the replaced text can be saved with "Download" as replaced.txt.

Formats and limits

Flavor
JavaScript RegExp only; named groups are written (?<name>…)
Flags accepted
d, g, i, m, s, u, v, y, each at most once
Time limit
2 seconds per test, then the worker is stopped and the pattern reported
Matches
Up to 5,000 found and highlighted; the first 200 listed in the table
Replacement
$1, $<name>, $&, and $$; with g every match is replaced, without g only the first

Where your pattern and text are processed

The pattern and your text are processed in a worker inside your browser; the text you test is never sent to our servers. If the pattern is invalid, the error message shown is sent to our error log with the tool's name and your browser's name and version; a time-out sends only the words "pattern timeout (2 s)". The message is cleaned first, but the cleaning may not hide everything: an invalid pattern containing quotes or angle brackets can reach the log as typed.

Frequently asked questions

Does it support Python or PCRE regex syntax?

No. Only JavaScript syntax is tested. Constructs such as possessive quantifiers, atomic groups, or Python's (?P<name>…) named groups are rejected as invalid; write named groups as (?<name>…) instead.

Does the replace preview change every match?

No, only with the g flag. The search adds g on its own so that every match is found (up to 5,000), but the replacement uses your flags as typed: without g, only the first match is replaced.

Can a slow pattern freeze the page?

No. The test runs in a separate worker that is terminated after 2 seconds; the page then says the pattern is probably backtracking catastrophically, as nested quantifiers like (a+)+ do on a long text that does not match.

Is there a limit on the number of matches?

Yes. The search stops at 5,000 matches, shown as 5000+, and the table lists the first 200; every match found is highlighted in the text above the table.

Tips and tricks

  • ✓Type each backslash once, as you would between /…/: \d in "Pattern" is a digit, while \\d matches a backslash followed by d.
  • ✓The v flag needs Safari 17 or later; older Safari versions report it as an invalid flag.