regex - evanmoran/quick GitHub Wiki
Modifiers
g All matches, not just the first
i Case-insensitive matching
m Multi-line matching
Characters
^ Beginning
$ End
* Zero or more
+ One or more
? Zero or one
{2} Two exactly
{2,4} Between Two and Four
. Any character
\s, \S White space, NOT whitespace.
\w, \W Word character, NOT word character. Same as: [a-zA-Z0-9]
\d, \D Digit character, NOT digit character. Same as: [0-9]
\1, \2, ... Match previous matches in the expression
() Match and remember part of the string. Referred to as \1 \2 etc
(aa|bb) Match 'aa' or 'bb'
[ab] Match the character a or b
[^ab] Match any character except a or b
a(?:b) Match an a followed by b
a(?=b) Match an a follow by b (capturing b)
a(?!b) Match an a not followed by b
a(?!=b) Match an a not followed by b (capturing b)
Examples
/^abc/ Match string that starts with 'abc'
/abc$/ Match string that ends with 'abc'
/abc/g Match all 'abc' strings
/abc/i Match the first 'abc' strings of any case
/(['"])\w+\1/ Match word surrounded by quotes of the same type