Skip to content
utilnest

Regex tester for JavaScript

Write a regular expression, see every match highlighted as you type, inspect capture groups and preview replacements.

  • Works in your browser
  • No sign-up
  • Free to use

How to use Regex tester

  1. 1

    Type your pattern into the "Regular expression" box, without slashes, or paste a full literal such as /\d+/g.

  2. 2

    Tick the flags you need. g finds every match, i ignores case, m makes ^ and $ work per line.

  3. 3

    Paste the text to search into "Test text". Matches are highlighted and listed with their position and groups.

  4. 4

    Switch to Replace to try a replacement such as $2/$1 or $<name>, then copy the result.

What this tool does

The regex tester compiles your pattern with JavaScript's RegExp and runs it against your test text after every change. Each match is highlighted in the text and listed in a table with its start and end position and the value of every capture group, numbered and named. Groups that didn't take part in a match are marked as such, so optional groups are easy to debug.

Replace mode shows the text after String.prototype.replace, so you can try out a substitution before using it in code.

Features

  • Live matching with a short delay while you type, and the time each run took.
  • All JavaScript flags: g, i, m, s, u, v, y and d.
  • Capture groups: numbered and named groups with their values, including groups that didn't match.
  • Replace preview with $1, $, $&, $` and $' substitutions.
  • Clear errors for invalid patterns and flags, using your browser's own error message.
  • Paste a literal like /^\w+$/gm and the pattern and flags are split out for you.
  • Protection against runaway patterns: each run is stopped after one second, and the tester recovers on the next change.

Limits

  • This is the JavaScript flavour only. PCRE, Python and .NET features that JavaScript lacks aren't available.
  • The list stops at 10,000 matches, and the table shows the first 500. That protects the page from patterns that match an empty string everywhere.
  • A pattern that is stopped after one second shows no partial results.

Where your text is processed

This tool works in your browser: what you type or paste is processed on your own device, so it isn't sent to our server for this tool. Some other tools on UtiloNest do use our server, and their pages say so.

Frequently asked questions

Which regex flavour does this use?

JavaScript's own RegExp engine in your browser, the same one your front-end or Node.js code uses. Patterns behave exactly as they will in your JavaScript. Syntax from other flavours, such as PCRE possessive quantifiers, atomic groups or inline (?i) modifiers, may be rejected or behave differently.

Why did my pattern stop with a time-out message?

Some patterns, like (a+)+$ tested against a long run of a's followed by another character, make the engine try an exponential number of ways to match. This is called catastrophic backtracking. The tester runs your regex in a separate worker and stops it after one second, so the page never freezes. Rewrite the pattern without nested quantifiers, or anchor it more tightly.

What do the d, v and y flags do?

d records the start and end of every capture group. v enables Unicode sets, such as [\p{L}--[a-z]], and stricter character-class syntax. y (sticky) only matches at the position where the previous match ended. If your browser is older than these flags, it says so.

How do I use capture groups in the replacement?

Use $1, $2 and so on for numbered groups, $<name> for a named group (?<name>…), $& for the whole match and $$ for a literal dollar sign. Without the g flag only the first match is replaced, just like String.prototype.replace.

Where is my text processed?

In your browser. This tool works on your own device, so what you type isn't sent to our server for it.

Was this tool helpful?