Regex Tester

Test and debug regular expressions in real-time

Test String

Results

Regex Cheat Sheet

Character Classes

.Any character except newline
\dDigit (0-9)
\DNot a digit
\wWord character (a-z, A-Z, 0-9, _)
\WNot a word character
\sWhitespace (space, tab, newline)
\SNot whitespace
[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Character range a to z

Anchors

^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNot a word boundary

Quantifiers

*0 or more
+1 or more
?0 or 1 (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Non-greedy (lazy) match

Groups & References

(abc)Capturing group
(?:abc)Non-capturing group
(?<name>)Named capturing group
\1Backreference to group 1
a|bMatch a or b (alternation)

Lookahead & Lookbehind

(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind

Common Patterns

\d+One or more digits
\b\w+\bHighlight words
\w+@\w+\.\w+Simple email
https?://\S+URL
\d{3}-\d{4}Phone (xxx-xxxx)
^.{8,}$At least 8 characters

About Regex Tester

This tool uses JavaScript's RegExp engine.
Remember to escape special characters like . * + ? ( ) [ ] { } \ ^ $ | with a backslash when you want to match them literally.