try see compare understand learn JavaScript Regular Expressions

Quick Reference

Basics
. (dot)Any character except newline
aThe character a
abThe string ab
a|ba or b
a*0 or more a's
\Escapes a special character
Quantifiers
*0 or more
+1 or more
?0 or 1
❴2❵Exactly 2 times
❴2,8❵Between 2 and 8 times
❴2,❵2 or more times
Character Classes
[a-z0-9]Any of a to z and 0 to 9
[^0-9]To exclude any of 0 to 9
\dDigit 0 to 9
\DNon digit
\sWhitespace
\SNon whitespace
\wA word
\WA non word
Anchors
^Start of string
$End of string
\bWord boundary
\BNon-word boundary
Options
gGlobal Match
iIgnore case
m^ and $ match start and end of line
Lookaround
(?:x)Non-capturing grouping
x(?=y)Positive lookahead
x(?!y)Negative lookahead
(?<=y)xPositive lookbehind
(?<!y)xNegative lookbehind