DevTools

Regex Tester

Build and test regular expressions live — highlight matches, inspect capture groups, and preview replacements.

Prefer the terminal? See the CLI equivalent →
Loading tool…

About the Regex Tester

  • Live match highlighting
  • Shareable link
  • Visualize as a railroad diagram
  • Instant results
  • 100% private — runs in your browser
  • Free, no sign-up

A regular expression (regex) is a compact pattern that describes a set of strings. Developers use them to validate input, search and extract data, and perform find-and-replace across text. Their power comes at the cost of readability: a pattern that looks right can quietly fail on an edge case, so testing against real sample text before shipping it is essential.

This tester lets you build a JavaScript regular expression and see it work in real time. Type a pattern and toggle flags, and every match in your test string is highlighted, with each capture group — numbered and named — listed underneath. Enable Replace to preview a substitution using $1 or

lt;name> references, exactly as String.prototype.replace would apply it.

It uses the browser’s native JavaScript regex engine, so what you see here behaves identically to the same pattern running in your code. Nothing is uploaded; your patterns and test data stay on your device.

How to use it

  1. Enter your regular expression in the pattern field.
  2. Toggle flags such as g (global), i (case-insensitive), m (multiline), and s (dotall) to change how matching behaves.
  3. Type or paste sample text; matches are highlighted live and capture groups are listed below.
  4. Turn on Replace and enter a replacement string using $1, $2, or
    lt;name> to preview the substituted result.
  5. Click “🚂 Visualize” to open the pattern as a railroad diagram with a plain-English explanation.

Common regex flags

g
Global — find all matches rather than stopping at the first.
i
Case-insensitive matching.
m
Multiline — ^ and $ match at line breaks, not just the start and end of the whole string.
s
Dotall — the dot (.) also matches newline characters.
u
Unicode — enables full Unicode matching and \u{...} escapes.

Frequently asked questions

Which regex flavour does this use?+

JavaScript (ECMAScript) regular expressions, via the browser’s built-in engine. Syntax and behaviour match what you would get from RegExp in Node.js or the browser. Patterns written for other flavours — PCRE, Python’s re, .NET — may differ in features like lookbehind or named-group syntax.

How do capture groups work?+

Parentheses create a capture group whose matched text you can reference later. Numbered groups are (…) and named groups are (?<name>…). This tool lists every group’s captured value for each match, and you can reference them in replacements as $1 or

lt;name>.

How do I preview a replacement?+

Enable Replace and enter a replacement string. Use $1, $2, … for numbered groups,

lt;name> for named groups, and
amp; for the whole match. The tool shows the resulting text with all matches substituted.

Why does my pattern match nothing / everything?+

Common causes are a missing g flag (so only the first match shows), unescaped special characters like . + * ? ( ) [ ] that need a backslash to match literally, or greedy quantifiers matching more than intended. Build the pattern incrementally and watch the highlights to narrow down the issue.

Is my test data private?+

Yes. Matching runs entirely in your browser with the native regex engine. Your pattern and test string are never sent anywhere.

Works well with

Regex Tester chains with these tools — send your result straight on:

Related tools