Back to All Tools

Regex Tester

Test JavaScript regular expressions with live highlighted matches, capture groups, flag toggles, and a quick cheatsheet.

Runs entirely in your browser — nothing is uploaded
//gm
Reach jane@example.com or sam.smith@dev.io for support.
jane@example.com $1=jane$2=example.com
smith@dev.io $1=smith$2=dev.io
Reach or sam. for support.
\ddigit 0-9
\wword char [A-Za-z0-9_]
\swhitespace
.any char (except newline)
^ $start / end of string
\bword boundary
a*0 or more
a+1 or more
a?0 or 1
a{n}exactly n
a{n,m}n to m
(x|y)alternation
(?:…)non-capturing group
(?<name>…)named group
[abc]char class
[^abc]negated class
(?=…)look-ahead
(?!…)negative look-ahead

About the Regex Tester

The Regex Tester lets you build a JavaScript regular expression and see every match highlighted in your own sample text as you type. Writing a pattern blind is slow, and one wrong quantifier can match too much or nothing. Here you edit the pattern in one box, paste your test string in another, and watch the matched spans light up instantly.

Your pattern sits between the slash delimiters, and the six flag buttons (g, i, m, s, u, y) append their letters to the trailing /flags label. The tool compiles it with the browser's own RegExp engine, so behavior matches your JavaScript at runtime. It counts the matches, highlights them, breaks out numbered capture groups, and if you fill the Replace with box it runs String.replace.

Patterns are matched by the browser's own RegExp engine, so it is free and no signup is needed. Nothing you paste is uploaded, because matching happens in local JavaScript with no network request. If your pattern is invalid, the compile error from the engine appears in red instead of failing silently, so you can fix the syntax right away.

How to use the Regex Tester

  1. 1Type your expression into the Pattern box between the / and /flags delimiters.
  2. 2Click the flag buttons (g, i, m, s, u, y) to toggle global, ignore case, multiline, dotAll, unicode, and sticky.
  3. 3Paste your sample into the Test string area and read the Highlighted matches count.
  4. 4Check the Capture groups list to see $1, $2 and group values per match.
  5. 5Enter a substitution in the Replace with box using $1 backreferences, and read the Result output.
  6. 6Use the Cheatsheet grid to recall tokens like \d, \b, (?:...), and lookaheads.

What you can use it for

Pull emails from text

Start from the default (\w+)@(\w+\.\w+) pattern, paste a block of contact text, and watch each address highlight. The capture groups split the local part and domain into $1 and $2 so you can confirm it first.

Debug a pattern that over-matches

When a greedy quantifier swallows more than expected, paste a real line and see the highlighted span run past its intended end. Adjust the pattern until only the target lights up, before it ships.

Preview a find-and-replace

Before a bulk substitution, put the search pattern in Pattern and the replacement in Replace with. Using $1 at $2 backreferences, the Result box shows the rewritten string so you can verify it first.

Learn regex tokens

Pick a token like \b or (?=...) from the Cheatsheet, drop it into Pattern, and change the test string to see where it matches. It makes abstract syntax visible.

Zero-width matches and the global flag

A regex can match an empty span. Patterns like a* or (?=x) succeed at a position without consuming any characters, so a naive loop calling exec would sit on the same index forever. This tool guards against that: after each match it checks whether the match began at the engine's lastIndex, and if so nudges lastIndex forward so scanning continues.

The g flag also changes the count. To build the highlight the tool always compiles a second copy of your pattern with g added, but keeps looping only when you enabled g yourself. Without g it records the first match and stops, like a plain RegExp in your code.

Frequently asked questions

Does my pattern or test string get sent to a server?

No. The pattern is compiled with the browser's built-in RegExp object, and every match, capture group, and replacement is computed in local JavaScript. There is no upload or network call, so your test string never leaves your machine.

Which regex flavor does it use?

JavaScript regular expressions, because it runs your input through the same RegExp engine your browser uses. Syntax that only exists in PCRE, Python, or .NET regex behaves the JavaScript way or throws a compile error instead of matching.

Why do I only see one highlighted match?

Highlighting depends on the global flag. Without g, matching stops after the first hit, so only that one is highlighted. Turn on the g flag button to scan the whole string and highlight every occurrence.

What are the flag buttons for?

Each toggles one JavaScript regex flag: g for global, i for ignore case, m for multiline so ^ and $ hit line boundaries, s for dotAll so a dot matches newlines, u for unicode, and y for sticky.

How do capture groups and replacements show up?

For each match, the parenthesized groups are listed as $1, $2 and so on, with an empty group shown as a dash. In the Replace with box you reuse those $1 backreferences, and the Result box shows String.replace applied.

What happens if my pattern is invalid?

The engine's error message is shown in red beneath the flag buttons, and the highlighted output falls back to your plain test string. So a stray unclosed group or bad escape tells you what went wrong immediately.