JavaScript Regex Online Tester
Pattern
/ /
Current Pattern: /
Match Result
Match Count: 0 Execution Time: 0ms JavaScript RegExp Engine
#ContentIndexLengthGroups
Replace Preview

JavaScript Regular Expression Metacharacter Cheat Sheet

ExpressionDescriptionExample
.Matches any character except newlinea.c
\dMatches digits (0-9)\d+
\DMatches non-digit characters\D+
\wMatches letters, digits, and underscores\w+
\WMatches non-word characters\W+
\sMatches whitespace characters (space, tab, newline)\s+
\SMatches non-whitespace characters\S+
\tMatches tab character\t
\nMatches newline character\n
\rMatches carriage return\r
^Matches start of string^hello
$Matches end of stringworld$
\bMatches word boundary\bcat\b
\BMatches non-word boundary\Bcat\B
*Matches previous element zero or more timesa*
+Matches previous element one or more timesa+
?Matches previous element zero or one timecolou?r
{n}Matches exactly n times\d{6}
{n,}Matches at least n times\d{2,}
{n,m}Matches between n and m times\d{2,5}
*?Non-greedy match<.*?>
[]Character set[abc]
[^]Negated character set[^0-9]
[a-z]Character range[a-z]+
()Capturing group(\d+)
(?:)Non-capturing group(?:abc)
(?=)Positive lookahead\d(?=px)
(?! )Negative lookahead\d(?!px)
(?<=)Positive lookbehind(?<=¥)\d+
(?<!)Negative lookbehind(?<!¥)\d+
|Logical ORcat|dog
\Escapes special characters\.
\uXXXXUnicode character\u4e2d
\xXXHexadecimal character\x41
\1Reference to first capturing group(a)\1
$1Reference first group in replacement[$1]