1. Home
  2. Developer
  3. Regex Tester

Regex Tester

Live match highlighting, capture group table and replace preview.

Runs in your browser · No upload Works offline
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g
$1, $2 for numbered groups, $<name> for named groups, $& for the whole match, $$ for a literal $

Your pattern and text are processed in this browser and never sent to a server.

How to use

  1. Type the pattern without the surrounding slashes. The full regex is shown below as /pattern/flags.
  2. Turn on the flags you need. Without g, only the first match is found.
  3. Matches in the test text are highlighted, and the table lists each match’s index and capture groups ($1, $<name>).
  4. Enter a replacement to preview the result of String.prototype.replace.

Flags

The tool uses your browser’s own JavaScript (ECMAScript) regex engine.

Flag Meaning Example
g global — find all matches, not just the first /\d+/g on a1b22 → 1, 22
i ignore case /abc/i matches ABC
m multiline — ^ and $ match at every line line-by-line checks
s dotAll — . also matches line breaks /a.b/s matches a(newline)b
u unicode — emoji count as one character, \p{…} classes work /./u matches 😀 once
y sticky — match only right where the last match ended tokenizers
d hasIndices — start and end of every group shown as [start–end] in the table

Examples

Goal Pattern Replacement
Reformat ISO dates as US dates (?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2}) $<m>/$<d>/$<y>
Mask a US phone number \(?(\d{3})\)?[-. ]?(\d{3})[-. ]?(\d{4}) ($1) ***-$3
Find hashtags #\w+ (flag g) —
Trim spaces at line ends ^\s+|\s+$ (flags gm) empty

\w matches only ASCII letters, digits and underscores. To include accented letters, use \p{L} with the u flag.

Things to watch out for

  • Catastrophic backtracking: a pattern with nested quantifiers, such as (a+)+$, can try an exponential number of paths when a match fails and freeze the browser. This tool runs the regex in a separate thread (a Web Worker) and stops it after 1 second. If such a pattern lives in server code, it’s a ReDoS vulnerability worth fixing.
  • Very large inputs are tested on the first 100,000 characters only, and up to 1,000 matches are shown.
  • JavaScript regex syntax differs slightly from PCRE, Python or Java. For example, JavaScript doesn’t accept a leading inline flag like (?i), and named groups are written (?<name>...).

FAQ

Is my text sent to a server?

No. The regex runs inside a worker in this browser, with no network requests, so it’s safe to test against logs or customer data.

How do I compare the result with the original?

Copy the replace result and paste it with the original into Text Diff to see every changed line. If you just want to clean up repeated lines, Remove Duplicate Lines is simpler.

Coming soon

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.