Regex

Regular Expression CheatSheat

Posted on Updated on

\d, \w, and \s match digit, word character, and whitespace
\D, \W, and \S (negate) match non-digt, non-word character, and non-whitespace
+ one or more times
* zero or more times (greedy)
*? zero or more times (lazy)
? zero or one time
^ matches beginning of line
$ matches end of line
{n,m} n to m times (inclusive), {n} exactly n times
[0-9] or [ABCdef] matches one character in set
[^0-9]+ leading circumflex (^) negates, so matches one or more non-digits
| match either pattern to left or pattern to right
() to define groups (referenced as $1, $2, …)
\ for literal next character — e.g., \? for literal question mark and \\ for backslash (\)