$ regex --test

regex tester.

Test regular expressions with real-time matching, group capture, and flags. 100% client-side.

input
pattern/\d{3}-\d{2}-\d{4}/gi
test string0 chars
matches
matches: 0
Enter a pattern and test string to see matches highlighted here.
The tool uses JavaScript regex syntax (ECMAScript), supporting flags like g (global), i (case-insensitive), m (multiline), and s (dotall).
Groups are defined with parentheses (). Each match's captured groups are shown below the test string. Named groups use (?<name>...) syntax.
test() returns true/false if a match exists. match() returns the matched string and groups. The tool uses match() with detailed highlighting.

Essential Patterns

PatternMatchesExample
.Any charactera.c → "abc", "a1c"
\dDigit [0-9]\d+ → "123"
\wWord char [a-zA-Z0-9_]\w+ → "hello_42"
\sWhitespacea\sb → "a b"
^Start of string^Hello → "Hello world"
$End of stringworld$ → "Hello world"
*0 or moreab*c → "ac", "abc"
+1 or moreab+c → "abc", "abbc"
?0 or 1 (optional)colou?r → "color"
{n,m}n to m times\d{3} → "123"

Groups & Assertions

(abc)         — capture group
(?:abc)        — non-capturing group
(?<name>abc)   — named group
a(?=b)         — positive lookahead (a followed by b)
a(?!b)         — negative lookahead (a NOT followed by b)
(?<=a)b       — positive lookbehind (b preceded by a)
(?<!a)b       — negative lookbehind (b NOT preceded by a)

Performance tip: Avoid catastrophic backtracking by not nesting quantifiers like (a+)+. Use atomic groups or possessive quantifiers where supported, and always test with long strings.

learn more in our detailed guide.

→ read the guide