Developer tool · free · runs in your browser

Regex Tester

Type a pattern and some sample text to see every match highlighted, with its position and capture groups. Add a replacement to preview the result. Matching runs in a background worker that is stopped if a pattern runs away.

Any of d g i m s u v y.
Use $1, $2 or $<name> for groups and $& for the whole match. Leave empty to skip.

What this regex tester does

The tester runs a JavaScript regular expression against sample text and shows every match highlighted in place, with its position and the value of each capture group. Add a replacement string to preview what String.replace would produce. It uses your browser's own regex engine, so the behavior matches the code you will write in JavaScript, TypeScript or Node.js. Matching runs in a background worker, and a pattern that takes too long is stopped instead of freezing the page.

How to test a pattern

  1. Type the pattern without the surrounding slashes: \d+, not /\d+/.
  2. Enter flags, such as g for all matches or gi to ignore case as well.
  3. Paste the text to search. Results update as you type.
  4. Optionally fill in Replace with to see the text after replacement.
  5. Read the highlighted preview and the match table, which lists each match, its index and its groups.

Flags in JavaScript

FlagNameEffect
gglobalFind all matches, not just the first
iignore casea also matches A
mmultiline^ and $ match at every line start and end
sdotAll. also matches line breaks
uunicodeCode-point matching and \p{...} property escapes
vunicodeSetsLike u, plus set operations in classes; cannot be combined with u
ystickyMatch only at the current position
dindicesRecord start and end positions of groups

Replacement patterns

In the replacement, $1 to $99 insert numbered groups, $<name> inserts a named group, $& inserts the whole match, $` and $' insert the text before and after the match, and $$ inserts a literal dollar sign.

Worked examples

Reformatting ISO dates

Pattern (\d{4})-(\d{2})-(\d{2}) with flag g on "Due 2026-11-26 and 2027-01-05." finds 2 matches at index 4 and 19. The replacement $3/$2/$1 gives "Due 26/11/2026 and 05/01/2027."

Named groups

Pattern (?<user>[\w.]+)@(?<domain>\w+\.\w+) on "a@b.com, c@d.org" without the g flag returns only the first match, a@b.com, with user=a and domain=b.com. Add g to get c@d.org as well.

First word of each line

^\w+ with gm on two lines, "one two" and "three four", matches "one" and "three". Without m, only "one" matches, because ^ then means the start of the whole text.

Catastrophic backtracking

Some patterns take exponential time when the text almost matches. The classic case is (a+)+$ on a long run of a's followed by a different character: the engine tries every way to split the a's between the inner and outer group before giving up. Each extra character roughly doubles the work: in a test on a desktop PC, 25 a's took about 4 seconds and 28 took about 30 seconds. The tester runs each pattern in a Web Worker and terminates it after 1.5 seconds, then tells you why. To fix such a pattern, remove the nested quantifier (a+$ matches the same text), or make the alternatives mutually exclusive so the engine has only one way to match.

Tips and common mistakes

Limits and privacy

Patterns can be up to 2,000 characters and the test text up to 200,000 characters. The table lists the first 200 matches and counting stops at 100,000. The highlighted preview covers the first 50,000 characters. Everything runs in your browser: the pattern and the text are never sent anywhere.

Frequently asked questions

Which regex flavor does this tester use?

The JavaScript engine in your browser, so results match what RegExp, String.match and String.replace do in your code. Syntax from PCRE or Python that JavaScript lacks, such as possessive quantifiers, is reported as a pattern error.

Why does it find only one match?

Without the g flag JavaScript stops after the first match. Add g to the flags to see every match.

What does the m flag change?

With m, ^ and $ match at the start and end of every line instead of only at the start and end of the whole text. The pattern ^\w+ with gm finds the first word of each line.

Why did my pattern stop with a timeout?

Patterns with nested quantifiers, such as (a+)+$, can take exponential time on text that almost matches. The tester runs matching in a separate worker and stops it after 1.5 seconds, so the page never freezes.

How do I use capture groups in the replacement?

Use $1 to $99 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign. The pattern (\d{4})-(\d{2})-(\d{2}) with $3/$2/$1 turns 2026-11-26 into 26/11/2026.

Are there size limits?

The pattern can be up to 2,000 characters and the test text up to 200,000. The match table lists the first 200 matches and the count stops at 100,000.

Is my text uploaded?

No. Matching runs in a Web Worker inside your browser and the page makes no network requests.