Kadben

Regex tester (JavaScript)

Try a JavaScript regular expression on your own text: every match is marked, groups and named groups are listed, and you see the result of a replace or split at once. A pattern that runs too long is stopped instead of freezing the page.

Runs in your browser. Nothing is uploaded.

Regex tester

JavaScript regular expressions, run by this browser’s own RegExp engine; other flavours (PCRE, Python, .NET, POSIX) differ in places.

Flags

How to use it

  1. Type the regular expression without the slashes, and tick the flags you need.
  2. Paste the text to test it on; the matches are marked as you type.
  3. Read the groups of each match in the table below.
  4. Optionally type a replacement ($1, $<name>, $&) or show the split result, and copy it.

Rules and limits

How the pattern is run

Questions and answers

Will my regex work the same in Python, PHP or Java?

Often, but not always. Lookbehind, named-group syntax, Unicode classes and what \w or $ match differ between flavours. This page answers for JavaScript only, as browsers and Node.js run it.

Why did the page stop my pattern?

Some patterns, such as (a+)+$, try an exponential number of ways on text that almost matches. A server running such a pattern can hang. The page stops it after 2 seconds; rewrite the nested repeat as a single one (a+$).

What do $1, $<name> and $& mean in the replacement?

$1 is the text of the first group, $<name> of the group named name, $& the whole match; $ and $' are the text before and after it, and $$ is a dollar sign.

Is my text sent anywhere?

No. The pattern runs in your browser, and the page cannot send anything. Only the chosen flags are kept, for this tab.

Related tools