Regex Tester Online — Free JavaScript Regular Expression Tester

Test regular expressions against sample text with live match highlighting, capture group inspection, and a replace preview — using your browser's native JavaScript regex engine.

//g
0 matches
Matches will be highlighted here as you type.

Replace Preview

What is a Regex Tester?

A regex tester runs a regular expression against sample text and shows you exactly what it matches — instantly, without switching to a REPL or re-running your program. This tool uses JavaScript's native RegExp engine, so behavior matches exactly what String.match(), String.replace(), and RegExp.test() will do in your actual code.

Beyond highlighting, it breaks out every match's numbered and named capture groups individually, and lets you preview a replace() call with real substitution syntax ($1, $<name>) before you commit it to code.

How to test a regex — 3 steps

  1. Write your pattern. Toggle flags (g, i, m, s, u) above the pattern field — the same flags you'd pass as the second argument to new RegExp().
  2. Paste test text. Matches highlight live as you type in either field, with a running match count.
  3. Inspect or replace. Check the match table for capture-group values, or open Replace Preview to see the exact output of a .replace() call.

Live Highlighting

Every match is highlighted inline in your test text as you type — no separate "run" step, no page reload.

Named & Numbered Groups

Capture groups are broken out per match, whether you used (group) or the more readable (?<name>group) syntax.

Real Replace Semantics

The replace preview runs an actual String.replace() call with your pattern and flags — what you see is exactly what your code will produce.

Common patterns to try

PatternMatches
\b\w+@\w+\.\w+\bSimple email addresses
^\s*$Blank or whitespace-only lines (with the m flag)
\d{4}-\d{2}-\d{2}ISO-style dates (YYYY-MM-DD)
(?<key>\w+)=(?<value>\w+)key=value pairs, captured by name
#[0-9a-fA-F]{6}\bHex color codes
https?:\/\/\S+HTTP(S) URLs

Working with structured text?

Pair the regex tester with the text and encoding tools — all run locally in your browser.

Frequently Asked Questions

Which regex flavor does this tool use?

This tool uses your browser's native JavaScript RegExp engine — the exact same engine that runs String.match(), String.replace(), and RegExp.test() in Node.js and every browser. Patterns you test here will behave identically in JS code, but may differ slightly from PCRE (PHP, Python's re module has its own dialect too), POSIX, or .NET regex — for example, JavaScript lacks recursive patterns and possessive quantifiers that some other engines support.

What do the g, i, m, s, u flags do?

g (global) finds every match instead of stopping at the first. i (ignore case) makes matching case-insensitive. m (multiline) makes ^ and $ match at line boundaries within the string, not just the very start/end. s (dotAll) makes . match newline characters too, which it normally does not. u (unicode) treats the pattern as a sequence of Unicode code points, enabling correct handling of characters outside the Basic Multilingual Plane and Unicode property escapes like \p{Emoji}.

Why is my pattern not matching anything?

Common causes: forgetting to escape special characters (., *, +, ?, (, ), [, ], {, }, ^, $, |, \ all need a backslash to match literally); missing the g flag when you expect multiple matches; using ^ or $ without the m flag when your test string has multiple lines; or a typo in a character class like [a-z] vs [a-Z] (invalid range). The live highlighting above updates as you type, so you can narrow down which part of the pattern is the problem by simplifying it piece by piece.

What is the difference between numbered and named capture groups?

A numbered group — (\w+) — is captured positionally: group 1, group 2, and so on, accessed as match[1], match[2] in JavaScript. A named group — (?<user>\w+) — is captured under a label you choose, accessed as match.groups.user. Named groups make patterns with several captures far more readable, especially when reordering or adding groups later, since positional indices don't shift.

How does the replace preview work?

It runs testString.replace(regex, replacement) exactly as JavaScript would. Use $1, $2, etc. in the replacement to reference numbered capture groups, or $<name> for a named group. Without the g flag, only the first match is replaced — this mirrors real JavaScript replace() behavior exactly, so what you see here is what your code will actually do.

Is my test data private?

Yes — matching runs entirely in your browser via the native RegExp engine. The pattern and test string you enter are never transmitted anywhere, which matters if you're testing a regex against real emails, log lines, or other sensitive sample data.