How to use this Regex Tester
- Enter your pattern. Type or paste a regex into the Pattern field. The
/.../delimiters and active flags are shown around it so you can copy them straight into JavaScript. - Toggle flags. Click
g,i,m,s,u, orydepending on how the pattern should behave. Changes take effect instantly. - Paste your test string. Matches highlight live. The stats row shows how many matches were found and how long the engine took.
- Check the Match details table. Each row shows the matched text, its capture groups, and the character index — useful when a replacement is producing unexpected output.
- Preview replacements. Enter a replacement string (using
$1,$2for capture groups and$&for the whole match) and click Replace All.
What is a regular expression?
A regular expression is a pattern that describes a set of strings. The engine walks the input and finds substrings that match the pattern. Regular expressions are used everywhere — validating form input, searching log files, extracting data from HTML, parsing config files, and splitting text into tokens.
Patterns are built from literals (like abc), character classes ([a-z], \d, \w), quantifiers (+, *, ?, {n,m}), groups ((...)), and anchors (^, $, \b). Combining these lets you describe almost any text format.
Regex cheat sheet
| Token | Meaning |
|---|---|
| . | Any character except newline (with s flag: any character) |
| ^ | Start of string (or line with m flag) |
| $ | End of string (or line with m flag) |
| \d / \D | Digit / not a digit |
| \w / \W | Word character (A-Za-z0-9_) / not a word character |
| \s / \S | Whitespace / not whitespace |
| \b | Word boundary |
| [abc] | Any of a, b, or c |
| [^abc] | Any character except a, b, or c |
| a* | Zero or more a's (greedy) |
| a+ | One or more a's |
| a? | Zero or one a |
| a{n,m} | Between n and m a's |
| a*? | Zero or more a's (lazy — matches as few as possible) |
| (abc) | Capture group — captured value is available as $1 |
| (?:abc) | Non-capturing group |
| (?<name>abc) | Named capture group |
| (?=abc) | Positive lookahead |
| (?!abc) | Negative lookahead |
| (?<=abc) | Positive lookbehind |
| (?<!abc) | Negative lookbehind |
| \1 | Backreference to capture group 1 |
Common mistakes when writing regex
- Forgetting the
gflag. Withoutg, only the first match is found. If your tool claims "1 match" and you can see three in the text, this is why. - Greedy vs lazy.
.*is greedy — it consumes as much as possible. To match the shortest valid string, use.*?. - Catastrophic backtracking. Nested quantifiers like
(a+)+or(.*)*cause the engine to try exponentially many paths on non-matching input. This tool warns you when it detects the pattern. - Unescaped special characters. A literal dot must be written as
\.. A literal(must be written as\(— otherwise the engine interprets it as the start of a group. - Mixing up
\band\B.\bis a word boundary — it matches between a word character and a non-word character.\Bis the opposite. - Ignoring multiline text.
^and$only match the start and end of the entire string by default. Addmto match line boundaries. - Unicode surprises. Without the
uflag, emoji and astral characters are treated as two code units. Useuwhenever your input may contain non-ASCII characters.
Why browser-based matters for regex testing
Regular expressions are often used on data that should never leave your device — API keys in config files, user records in log files, personally identifiable information in dumps. A server-based regex tester has to send that input to the server, which means it exists in their logs. This tool does everything in the browser using the native JavaScript RegExp engine. Nothing you type is uploaded.
That is also why the pattern here behaves exactly as it will in your JavaScript code — it uses the same engine, not a PCRE approximation or a translated dialect.