Regex Tester

Try a JavaScript regular expression against sample text and see every match highlighted, with capture groups listed and a replace preview underneath. It is free, updates as you type, and nothing leaves your browser.

Regex TesterPrivate · runs on your device
Presets:
Test string
Matches
Enter a pattern to see matches.

How to use the regex tester

The left side takes your pattern and test text, and the right side shows the result.

  1. Type your pattern into Regular expression without the surrounding slashes, or click a preset: Email, URL, IPv4, Date (YYYY-MM-DD), Numbers or Hex colour.
  2. Check the Flags box. It starts as g, and only the letters g i m s u y are accepted, so anything else you type is ignored.
  3. Paste your text into Test string. Matches are highlighted in the Matches panel, with a count and a list of capture groups beneath.
  4. Optionally fill in Replace matches with. It supports $1 and $<name>, and the Replace preview shows the rewritten text.
  5. Click Copy replaced text to take the result away.

If the pattern is invalid, the browser's own error message appears under the matches, for example an unterminated group.

Flags, groups and a worked replacement

Flags change how the engine reads a pattern. i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u turns on full Unicode matching including \p{L}, and y makes a match start exactly where the last one ended. The newer d and v flags are not accepted here.

One detail matters when you copy a pattern elsewhere. The highlighting always finds every match, even if you remove g, but the replace preview uses your flags exactly as typed. Try the pattern (\d{4})-(\d{2})-(\d{2}) on the text Due 2026-11-03 and 2026-12-25, with the replacement $3/$2/$1. With g you get Due 03/11/2026 and 25/12/2026. Without it only the first date changes, which is exactly what your code would do.

Capture groups are listed per match in the form Match 1 @4: $1 = "2026", $2 = "11", $3 = "03", where the number after the at sign is the position in the text. A named group such as (?<year>\d{4}) is listed by its name and can be reused as $<year>.

Common pitfalls and limits

The tester runs your browser's JavaScript engine, so lookbehind, named groups and Unicode property escapes behave as they will in Node.js and front-end code, but not necessarily as in PHP, Python or Java. Counting stops at 5,000 matches and the group list shows details for the first 50.

  • An unescaped dot matches any character, so write \. for a literal full stop.
  • Use \b for word boundaries: \bcat\b matches the word cat but not the cat inside concatenate.
  • Without the u flag, an emoji counts as two characters, so . matches only half of it. Add u when you work with emoji or characters outside the basic range.
  • Do not type the slashes around the pattern, as in /abc/g. The flags have their own box.
  • Greedy .* runs to the last possible match; use .*? to stop at the first.
  • Without the m flag, ^ and $ match only the start and end of the whole text.
  • Nested repeats such as (a+)+$ can take exponential time on a failing match and may freeze the tab, so shorten the test text if the page stalls.
  • The presets are rough starting points. The email preset shows what an address looks like, but it cannot confirm that a mailbox exists.

It helps to know what each preset really matches. Date (YYYY-MM-DD) checks the shape only, so 2026-13-45 matches. IPv4 accepts 999.999.999.999. Hex colour needs exactly six digits, so the short form #fff is not found. Numbers matches runs of digits, so 3.5 is read as two numbers, 3 and 5, and a minus sign is not included. Edit the preset text in the box to tighten any of these.

To apply a replacement without patterns, use the find and replace tool. To compare the before and after text, paste both into the diff checker, and to clean the result of a JSON extraction try the JSON formatter. Pattern and text are evaluated locally and are not uploaded.

Quick answers

Frequently asked questions

The questions people ask most, answered in plain words.

Which regex flavour does this tester use?

It uses the JavaScript regular expression engine built into your browser, the same one that runs in Node.js and front-end code. Many patterns carry over to PHP, Python and Java, but lookbehind, named groups and Unicode escapes differ in places, so test in your target language too.

Why does the replace preview change only the first match?

The replace preview applies your flags exactly as typed, so without g only the first match is replaced, just as in JavaScript. The highlighting always shows every match, which can make the two look inconsistent. Add g to the Flags box to replace all matches.

How do I use capture groups in the replacement?

Wrap the part you want in parentheses, then write $1, $2 and so on in the Replace matches with box. For a named group such as (?<year>\d{4}), write $ followed by the name in angle brackets. The Replace preview updates as you type.

Which flags can I use?

The Flags box accepts g, i, m, s, u and y, and ignores any other letters. g finds all matches, i ignores case, m makes anchors work per line, s lets the dot match line breaks, u enables Unicode matching, and y anchors each match to the previous position.

Is my test data sent anywhere?

No. The pattern and the text are evaluated by JavaScript in your browser and are not uploaded. You can test against log lines, customer records or source code, although it is sensible to remove real personal data from anything you paste into a web page.