Skip to content

Latest commit

聽

History

History
75 lines (73 loc) 路 2.95 KB

File metadata and controls

75 lines (73 loc) 路 2.95 KB

Regular Expression Cheat Sheets and Resources

Quick Regex Reference

Character Meaning Example
* Match聽zero, one or more聽of the previous Ah*聽matches "Ahhhhh" or "A"
? Match聽zero or one聽of the previous Ah?聽matches "Al" or "Ah"
+ Match聽one or more聽of the previous Ah+聽matches "Ah" or "Ahhh" but not "A"
\ Used to聽escape聽a special character Hungry\?聽matches "Hungry?"
. Wildcard character, matches聽any聽character do.*聽matches "dog", "door", "dot", etc.
( ) Group聽characters See example for聽|
[ ] Matches a聽range聽of characters [cbf]ar聽matches "car", "bar", or "far"
[0-9]+聽matches any positive integer
[a-zA-Z]聽matches ascii letters a-z (uppercase and lower case)
[^0-9]聽matches any character not 0-9.
| Matche previous聽OR聽next character/group (Mon|Tues)day聽matches "Monday" or "Tuesday"
{ } Matches a specified聽number of occurrences聽of the previous [0-9]{3}聽matches "315" but not "31"
[0-9]{2,4}聽matches "12", "123", and "1234"
[0-9]{2,}聽matches "1234567..."
^ Beginning聽of a string. Or within a character range聽[]聽negation. ^http聽matches strings that begin with http, such as a url.
[^0-9]聽matches any character not 0-9.
$ End聽of a string. ing$聽matches "exciting" but not "ingenious"

聽