/ Regex Tester
All Tools
/ /
Test String
Match Details
Enter a pattern to see matches
Result

Characters

.Any character (except newline)
\dDigit [0-9]
\DNot digit [^0-9]
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace
\SNon-whitespace
\nNewline
\tTab
\xHHHex character
\uHHHHUnicode character

Quantifiers

*Zero or more
+One or more
?Zero or one (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Zero or more (lazy)
+?One or more (lazy)
??Zero or one (lazy)

Anchors

^Start of string/line
$End of string/line
\bWord boundary
\BNon-word boundary
\AStart of string only
\ZEnd of string only

Groups & Lookaround

(...)Capturing group
(?:...)Non-capturing group
(?<name>...)Named capturing group
\1, \2Backreference
(?=...)Lookahead
(?!...)Negative lookahead
(?<=...)Lookbehind
(?<!...)Negative lookbehind

Character Classes

[abc]Any of a, b, or c
[^abc]Not a, b, or c
[a-z]Character range a to z
[a-zA-Z]Uppercase and lowercase

Flags

gGlobal - find all matches
iCase insensitive
mMultiline (^/$ per line)
sDotall (. matches \n)
uUnicode support

Replacement Patterns

$&Entire match
$1, $2Capture group
$`Before match
$'After match
$$Literal $

Special

|Alternation (OR)
\Escape special character
\k<name>Named backreference