Regex Reference Cheatsheet

If you are trying to make sense of a regex or want a go to regex reference
Tags : regex

Match Characters
Match digit

Match lowercase letter

Match uppercase letter

Match alphanumeric

Match exceptions

Match one

/\d/   digit
/\D/   non-digit
/\w/   word character (a-z, A-Z, 0-9, _)
/\W/   non-word character
/\s/   any white space character \r, \n, \t, \f (form feed)
/\S/   non-white space character
Match all characters but new line

Match any character 0 or more times

Match "b" 0 or more times

Match 1 or more times

Match "b" 1 or more times
Match "repeat" 3 times

Match "repeat" 1 to 3 times

Match "repeat" at least 3 times

3 or more "t" - example "repeattt"


Positive lookahead, matches "a" before "bc"

Negative lookahead, matches a "a" that is not before expr "bc"

Positive lookbehind, matches "bc" after "a"

Negative lookbehind, matches "bc" that is not after "a"