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

SyntaxMeaning
.Any character except newline (unless the s flag is set)
\d / \DDigit / non-digit
\w / \WWord character ([A-Za-z0-9_]) / non-word character
\s / \SWhitespace / 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

SyntaxMeaning
^Start of string (or line, with the m flag)
$End of string (or line, with the m flag)
\b / \BWord boundary / non-word-boundary

Quantifiers

SyntaxMeaning
*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

SyntaxMeaning
(...)Capturing group
(?:...)Non-capturing group
(?<name>...)Named capturing group (shown separately in results)
a|bAlternation — a or b

Lookaround

SyntaxMeaning
(?=...)Positive lookahead
(?!...)Negative lookahead
(?<=...)Positive lookbehind
(?<!...)Negative lookbehind

Flags

FlagMeaning
gGlobal — find all matches, not just the first
iCase-insensitive
mMultiline — ^/$ match at line boundaries, not just string boundaries
sDotall — . also matches newlines
uUnicode — correct handling of astral code points (e.g. emoji) and stricter syntax validation
ySticky — matches only starting exactly at lastIndex, no scanning ahead
dGenerates start/end indices for each capture group (not shown separately in this tool's output, but a valid flag)

Examples

PatternFlagsTest stringMatches
\d+gabc 123 def 456123, 456
(\w+)@(\w+)alice@examplealice@example (groups: alice, example)
(?<year>\d{4})-(?<month>\d{2})g2023-11 and 2024-01named groups: {year: "2023", month: "11"}, {year: "2024", month: "01"}
\d+(?=px)width: 10px10 (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).