Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
107 views

Regular Expressions Regex Cheat Sheet

Regular expressions (regex) are used to match patterns in text. This document lists special characters in regex and their meanings, including: * to match zero or more of the previous character ? to match zero or one of the previous character + to match one or more of the previous character . as a wildcard to match any single character [] to match a range or set of characters ^ and $ to match the start or end of a string respectively {n,m} to match a specified number of occurrences of the previous character | for alternation to match either expression separated by the pipe

Uploaded by

Red Grey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

Regular Expressions Regex Cheat Sheet

Regular expressions (regex) are used to match patterns in text. This document lists special characters in regex and their meanings, including: * to match zero or more of the previous character ? to match zero or one of the previous character + to match one or more of the previous character . as a wildcard to match any single character [] to match a range or set of characters ^ and $ to match the start or end of a string respectively {n,m} to match a specified number of occurrences of the previous character | for alternation to match either expression separated by the pipe

Uploaded by

Red Grey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like