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