RegEx Tester
Test a regular expression against a string. Uses the JavaScript RegExp engine, runs entirely in your browser.
How it works
This uses JavaScript's native RegExp engine (not PCRE or .NET regex —
syntax differs slightly between engines). With the g flag, all matches are
found; without it, only the first. Named capture groups ((?<name>...))
are shown separately from positional groups in the result.
Syntax reference
Character classes
| Syntax | Meaning |
|---|---|
. | Any character except newline (unless the s flag is set) |
\d / \D | Digit / non-digit |
\w / \W | Word character ([A-Za-z0-9_]) / non-word character |
\s / \S | Whitespace / non-whitespace |
[abc] | Any one of a, b, c |
[^abc] | Any character except a, b, c |
[a-z] | Any character in the range a to z |
Anchors
| Syntax | Meaning |
|---|---|
^ | Start of string (or line, with the m flag) |
$ | End of string (or line, with the m flag) |
\b / \B | Word boundary / non-word-boundary |
Quantifiers
| Syntax | Meaning |
|---|---|
* | 0 or more |
+ | 1 or more |
? | 0 or 1 |
{n} | Exactly n |
{n,} | n or more |
{n,m} | Between n and m |
*?, +?, ?? | Lazy (non-greedy) versions of the above |
Groups & alternation
| Syntax | Meaning |
|---|---|
(...) | Capturing group |
(?:...) | Non-capturing group |
(?<name>...) | Named capturing group (shown separately in results) |
a|b | Alternation — a or b |
Lookaround
| Syntax | Meaning |
|---|---|
(?=...) | Positive lookahead |
(?!...) | Negative lookahead |
(?<=...) | Positive lookbehind |
(?<!...) | Negative lookbehind |
Flags
| Flag | Meaning |
|---|---|
g | Global — find all matches, not just the first |
i | Case-insensitive |
m | Multiline — ^/$ match at line boundaries, not just string boundaries |
s | Dotall — . also matches newlines |
u | Unicode — correct handling of astral code points (e.g. emoji) and stricter syntax validation |
y | Sticky — matches only starting exactly at lastIndex, no scanning ahead |
d | Generates start/end indices for each capture group (not shown separately in this tool's output, but a valid flag) |
Examples
| Pattern | Flags | Test string | Matches |
|---|---|---|---|
\d+ | g | abc 123 def 456 | 123, 456 |
(\w+)@(\w+) | alice@example | alice@example (groups: alice, example) | |
(?<year>\d{4})-(?<month>\d{2}) | g | 2023-11 and 2024-01 | named groups: {year: "2023", month: "11"}, {year: "2024", month: "01"} |
\d+(?=px) | width: 10px | 10 (the "px" itself is not part of the match) |
FAQ
What happens with an invalid pattern? You'll see a clear error message instead of a silent failure — e.g. unbalanced parentheses or an unknown flag.
Why isn't PCRE or .NET regex syntax fully supported? This tool uses the browser's built-in JavaScript RegExp engine, so it can run entirely client-side without a server. Syntax is very similar to PCRE/.NET but not identical (e.g. possessive quantifiers and atomic groups aren't supported in JavaScript).