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.

Basic Metacharacters

. (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.
Match exactly x times.
Match between x and y times.
Match at least x times.

Shorthand Character Classes

Anything which is considered whitespace.
Anything which is not considered whitespace.
A digit (ie. 0 - 9)
Anything which is not a digit.
Anything which is considered a word character.
Anything which is not considered a word character.

Non printable characters

Carriage return
Newline (or line feed)

Anchors and Word Boundaries

The beginning of the line.
The end of the line.
The beginning of a word.
The end of a word.
The beginning or end of a word.

Grouping and backreferences

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.

Lookahead and Lookbehind

A positive lookahead.
A negative lookahead.
A positive lookbehind.
A negative lookbehind.