Regex Tester

Write a regular expression and see what it matches as you type: every match highlighted in your text, with capture groups, flags and a replace preview.

Flags

In JavaScript: /(\d{2})\/(\d{2})\/(\d{4})/g

$1, $2… for numbered groups, $<name> for named ones, $& for the whole match.

JavaScript regular expressions, run in your browser; the pattern and text aren't sent anywhere. Indexes count UTF-16 code units, so an emoji counts as 2.

How to use it

  1. Type a pattern, or pick one from Common patterns to start from.
  2. Switch flags on or off. The line under them shows the regex as you'd write it in JavaScript.
  3. Paste your test text: matches are highlighted and listed with their index and groups.
  4. Optionally enter a replacement to preview the result, and copy it.

Example

The pattern (\d{2})/(\d{2})/(\d{4}) on “Invoice dated 15/08/2026, due 30/09/2026.” finds 2 matches. Replacing with $3-$2-$1 turns the dates into 2026-08-15 and 2026-09-30.

Quick reference

  • \d digit, \w letter, digit or underscore, \s space; capitals mean “not” (\D).
  • . any character, [abc] one of a, b or c, [^abc] anything else.
  • * 0 or more, + 1 or more, ? optional, {2,4} 2 to 4 times; add ? to match as little as possible.
  • ^ start, $ end, \b word boundary.
  • (…) group, (?<name>…) named group, (?:…) group without capturing, a|b either.
  • (?=…) followed by, (?!…) not followed by, (?<=…) preceded by.

The common patterns cover emails, URLs, dates, times, phone numbers in international (E.164) form, IP addresses, colours, UUIDs, and US, UK and Indian postcodes. They're for finding typical text, not strict validation: check important input on your server too.

Frequently asked questions

Which regex flavour is this?

JavaScript (ECMAScript), as used by browsers and Node.js. Most syntax is shared with PCRE, Python and Java. Differences to watch: named groups are written (?<name>…) (Python's (?P<name>…) isn't accepted), and possessive quantifiers and atomic groups aren't supported.

What do the flags do?

g finds every match instead of the first; i ignores case; m makes ^ and $ match at the start and end of each line; s lets . match line breaks; u turns on full Unicode, so an emoji is one character and \p{L}-style classes work; y matches only from the current position.

How do I use groups in the replacement?

$1, $2 and so on insert numbered groups, $<name> inserts a named group, $& inserts the whole match and $$ gives a literal dollar sign. Without the g flag only the first match is replaced.

What does 'timed out' mean?

The pattern took over a second, usually because of catastrophic backtracking, as in ^(a+)+$ on a long line that almost matches. Make the repeated parts more specific so they can't overlap.

Why do emoji count as two in the index?

JavaScript strings count UTF-16 code units, and most emoji take two. Turn on the u flag so that . and character classes treat each emoji as one character.

Is my text sent anywhere?

No. The pattern runs in your browser, in a separate worker that's stopped after a second so a slow pattern can't freeze the page.

More text and developer tools

See all text and developer tools →

Can't find the tool you need? Tell us.