ToolDash
Regex Tester

Regex Tester for JavaScript

Type a pattern, paste some text, and see every match highlighted as you go. Each match lists its position and capture groups, and the replace preview shows exactly what String.replace would return.

  • Free, no sign-up
  • Runs in your browser — nothing is uploaded
  • Instant results, no waiting on a server

Test JavaScript regular expressions live: matches are highlighted as you type, capture groups are listed per match, and the replace preview shows exactly what String.replace returns.

//g

Flags

Test string

128 chars

Matches
Matches will be highlighted here.
Match details
Match positions and capture groups will appear here.
Replace

$& whole match · $1…$99 groups · $<name> named group · $$ literal $

The replaced text will appear here.

How to test a regular expression

  1. 1Type your pattern into the Regular expression field without the surrounding slashes, for example \d{3}-\d{4}.
  2. 2Toggle the flags you need: g for all matches, i for case-insensitive, m for multiline anchors, s so . matches newlines, u for Unicode mode and y for sticky matching.
  3. 3Paste the text to test into the Test string panel. Matches are highlighted on the right, and Match details lists each match's index range and capture groups.
  4. 4To try a substitution, type a replacement such as $1 or $<name> into the Replace field and copy the result.

What this regular expression tester does

This JavaScript regex tester uses your browser's own RegExp engine, the same one that runs String.match, matchAll and replace in your JavaScript or TypeScript code. There's no translation layer, so if a pattern behaves a certain way here, it behaves the same way in Chrome, Node.js, Deno or Bun. Syntax that only exists in other flavors, like PCRE's possessive quantifiers or Python's (?P<name>…) groups, will be reported as an error rather than silently accepted.

Without the g flag, a regex stops at the first match, which is what RegExp.exec and String.match do. With g, every match is found. Zero-length matches, such as ^ with the m flag or a* against text without any a, are drawn as a thin caret so you can see where they land. The list stops at 1,000 matches to keep the page fast, and the count tells you when that limit was hit.

For each match, the details panel shows the start and end index and every numbered group from $1 upwards. Named groups written as (?<name>…) show their name beside the number. A group that didn't take part in the match shows as undefined, which is what your code will see too.

Some patterns take exponential time on certain inputs. The classic case is a nested quantifier like (a+)+$ against a long run of a's followed by a character that doesn't fit. To keep the page responsive, matching runs in a Web Worker. If a run takes longer than two seconds, the worker is stopped and you get a warning about catastrophic backtracking instead of a frozen tab.

When developers reach for it

Validating input formats

Check an email, phone, postcode or slug pattern against a list of good and bad examples before it goes into a form validator.

Extracting data from logs

Paste a chunk of log output and build a pattern with capture groups that pulls out timestamps, IDs or status codes.

Planning a find-and-replace

Preview a bulk rename or refactor with $1 and $<name> references before running it in your editor or a script. Doing the regex replace online first, on a pasted sample, means a wrong group reference costs you nothing.

Debugging a slow regex

Find out whether a pattern backtracks badly on a particular input without locking up your browser or your server.

Frequently asked questions

Which regex flavor does this tester use?

+

JavaScript (ECMAScript). It's a RegExp tester in the literal sense: patterns run through the same RegExp object your code uses. Results match what you'll get in browsers and in Node.js. Lookbehind, named groups and Unicode property escapes like \p{L} with the u flag are all supported in current browsers.

Why does my pattern only find one match?

+

Turn on the g (global) flag. Without it, JavaScript stops at the first match, both here and in String.match and String.replace.

How do I reference capture groups in the replacement?

+

Use $1, $2 and so on for numbered groups, $<name> for named groups, $& for the whole match, and $$ for a literal dollar sign. These are the same tokens String.replace understands.

What does the 'Stopped after 2 seconds' message mean?

+

Your pattern took too long on this input, almost always because of catastrophic backtracking from nested or overlapping quantifiers like (a+)+ or (\w*)*. Make the inner part more specific, or remove the nesting, so the engine has fewer ways to split the text.

Is it safe to run a regex test online on real log data?

+

Yes. The pattern and test string are evaluated in a Web Worker inside your own browser tab. Nothing is uploaded or stored.

Can I use it as a regex checker for syntax errors?

+

Yes. If a pattern doesn't compile, the field is marked as invalid and a banner shows the RegExp constructor's own error message, for example for an unterminated group or an invalid escape in u mode.