Test and debug regular expressions with live match highlighting — free, fast, private.
What is a regex tester?
A regex tester is an online scratchpad for regular expressions: you type a pattern and a sample
text, and the tool instantly shows which parts of the text match, where each match starts, and what
every capture group caught. Instead of editing code and re-running a script, you see the effect of
every change live, which makes it the fastest way to build, debug and fine-tune a regular expression.
How to use this tool
- Type or paste your pattern into the pattern field — without the surrounding slashes.
- Toggle the flag checkboxes (g, i, m, s, u, y) to change how the engine matches.
- Enter a test string: matches are highlighted live and listed below with their index and capture groups.
- For find & replace, type a replacement —
$1, $2 … insert capture groups — then copy the result.
Quick cheatsheet
\d any digit, \w word character (letter, digit, _), \s whitespace
. any character except a line break (any character at all with the s flag)
* zero or more, + one or more, ? zero or one
^ start of string (or line with m), $ end of string (or line with m)
[abc] one character from the set, [^abc] one character not in the set
(abc) capture group — reuse it in replacements as $1
Common regex mistakes (and how to fix them)
- Greedy matching eats too much. The pattern
<.+> on <b>one</b> <i>two</i> matches the whole line, not each tag, because + is greedy. Add a question mark to make it lazy: <.+?> — the match list will show two separate hits instead of one long one.
- Nested quantifiers cause catastrophic backtracking. A pattern like
(\w+)+$ can hang for seconds on a non-matching string such as 30 word characters followed by !, because the engine tries exponentially many ways to split the text. Rewrite it as \w+$ or make the inner group possessive by design: (\w+\s?)+$.
- Zero-length matches surprise people. Patterns like
\d* or .* match an empty string at every position. The tester caps output at 500 matches and steps past empty matches, so long texts may show the truncated notice — tighten the pattern to require at least one character.
Worked example: swap names with find & replace
Test string: Smith, John. Pattern: (\w+), (\w+). Replacement: $2 $1. The match list shows $1 = Smith and $2 = John, and the replace output reads John Smith. Add more names on separate lines and enable the g flag (on by default) to convert the whole list at once, then press Copy result.
Frequently asked questions
What is a regular expression?
A regular expression (regex) is a compact pattern language for describing sets of strings. It is used to search, validate, split and transform text — for example checking that an email address looks valid or extracting every date from a document.
What do the flags g, i, m, s, u and y do?
g (global) finds every match instead of stopping at the first; i makes matching case-insensitive; m lets ^ and $ match at line boundaries; s (dotAll) lets the dot match line breaks; u enables full Unicode mode; y (sticky) forces the match to start exactly at the current position.
Which regex flavor does this tester use?
It uses the JavaScript flavor — the patterns you type are compiled by your own browser's RegExp engine. Modern features such as lookbehind and named capture groups work in all current browsers, and the results you see are exactly what JavaScript would produce.
How do I match special characters like a dot or an asterisk literally?
Prefix them with a backslash: \. matches a literal dot, \* a literal asterisk, \( and \) literal parentheses, and \\ a literal backslash. Inside a character class most special characters lose their meaning, so [.] already matches a plain dot.