Skip to content

Regex tester (JavaScript)

Test JavaScript regular expressions with live highlighting, groups, replace and a plain-language explanation. Runs in your browser.

Flags

JavaScript (ECMAScript) regex flavor

Test text

0 characters

Matches

Nothing to show yet

Enter a pattern and some text. Matches are highlighted here.

How to test a regular expression

  1. Type the pattern without the surrounding slashes, for example \d{3}-\d{4}, and tick the flags you need.
  2. Paste the text to test. Matches are highlighted as you type, and each match is listed with its position and its numbered and named groups.
  3. Choose Replace to preview a replacement such as $<year>-$2, then copy or download the result.
  4. Open Explanation to see what each part of the pattern does in plain language. Syntax it doesn’t cover is marked “Not explained”.

Replacement patterns

$1, $2 …
The text of a numbered group.
$<name>
The text of a named group (?<name>…).
$&
The whole match.
$` and $'
The text before and after the match.
$$
A literal dollar sign.

Safe by design

Patterns run in a separate background thread, never on the page itself. If a pattern runs for more than 1 second, for example because of catastrophic backtracking, the thread is stopped and replaced, and the page stays responsive. The explanation is produced by reading the pattern, without running it.

Troubleshooting

  • Only one match is found. Turn on the g flag to find all matches.
  • “This pattern took too long.” Nested quantifiers like (a+)+ or (.*)* can backtrack exponentially. Make them more specific or remove the nesting.
  • \p{L} doesn’t match letters. Without the u or v flag, JavaScript reads it as the literal text p{L}. Turn on u to use Unicode property classes.
  • Not every match is listed. The first 200 matches are listed and up to 5,000 are highlighted; the count includes all of them. In text longer than 200,000 characters, only the start is highlighted.

How your data stays private

Everything happens in your browser, on your device. Your files and text are never uploaded, never stored, and never put in the address bar.

  • The site’s security policy (connect-src 'self') tells your browser to block any attempt by the page to send data to another server.
  • Only your preferences, such as the theme and a tool’s last-used options, are saved in your browser’s local storage. Never your content.
  • To check it yourself, open your browser’s developer tools, select the Network tab, and use the tool: no request carries your data.

There is no account, no sign-up and no watermark. After your first visit, pages open without a connection; a tool’s larger parts, such as the PDF and image engines, are saved the first time you use it, so it works offline from then on.

Frequently asked questions

Which regex flavor does this use?

JavaScript (ECMAScript), exactly as your browser runs it, so results match RegExp, String.match, matchAll and replace in your code. All current flags are supported: g, i, m, s, u, v, y and d (v where the browser supports it).

Why does my regex work here but not in Python?

Regex flavors differ. Python, PCRE (PHP), Java and .NET support features JavaScript doesn’t, such as possessive quantifiers (a++), atomic groups or a (?i) flag at the start of the pattern, and some syntax differs, such as named groups written (?P<name>…) in Python. Patterns made of common building blocks behave the same everywhere; test anything advanced in the target language too.

What do the flags mean?

g finds all matches instead of the first; i ignores case; m makes ^ and $ match at line breaks; s lets . match line breaks; u enables full Unicode, including \p{…} classes; v is a stricter, newer form of u with set operations; y matches only at the position where the last match ended (sticky); d records where each group matched.

Why did my regex time out?

Some patterns, such as (a+)+$, can try an enormous number of ways to match before failing: catastrophic backtracking. Every test runs in a background thread that is stopped after 1 second, so the page never freezes. Make quantifiers more specific, avoid nested repetition of the same characters, and anchor the pattern where you can.

Is my text uploaded?

No. The pattern and the text are tested in your browser, on your device. Nothing is uploaded, stored or put in the URL. Only your flag and mode choices are remembered on this device.