This cheat sheet is intended to be a quick reminder for the main concepts involved in using regular expressions and assumes you already understand their usage. If you are new to regular expressions we strongly suggest you work through the Regular Expressions tutorial from the beginning.
Click the title of a section to be taken to the relevant tutorial page to learn more about those concepts.
- . (dot or fullstop)
- Any character.
- [ ]
- Range. Match any of these characters.
- [^ ]
- Range. Match any character which is not one of these.
- \ (backslash)
- Escape. Remove or add special meaning to a character.
- *
- Match zero or more times.
- +
- Match one or more times.
- ?
- Match zero or one times.
- {x}
- Match exactly x times.
- {x,y}
- Match between x and y times.
- {x,}
- Match at least x times.
- \s
- Anything which is considered whitespace.
- \S
- Anything which is not considered whitespace.
- \d
- A digit (ie. 0 - 9)
- \D
- Anything which is not a digit.
- \w
- Anything which is considered a word character.
- \W
- Anything which is not considered a word character.
- \t
- Tab
- \r
- Carriage return
- \n
- Newline (or line feed)
- ^
- The beginning of the line.
- $
- The end of the line.
- \<
- The beginning of a word.
- \>
- The end of a word.
- \b
- The beginning or end of a word.
- May be used anywhere in any path.
- ( )
- Create a grouping.
- \x (x = digit)
- Match what was matched in the corresponding grouping.
- |
- Match what is on the left, or, what is on the right of the pipe symbol.
- (?=x)
- A positive lookahead.
- (?!x)
- A negative lookahead.
- (?<=x)
- A positive lookbehind.
- (?<!x)
- A negative lookbehind.