Memos - Regex cheat sheet

All meta-characters

^ , . , [ , ] , $ , ( , ) , * , + , ? , | , { , } , \ , ! , < , > , = , :

Symbols

^ : start of a string

$ : end of a string

. : any char

* : 0, 1 or more occurences

+ : 1 or more occurences

? : 0 or 1 occurences

| : alternative "or"

Intervals

a{3} : match exactly "aaa"

a{2,} : match at least 2 consecutive "a"

a{2,4} : match 2, 3, or 4 consecutive "a"

Character classes

[...] : define a char class

[^...] : define a complemented class

[...-...] : define an interval

Scope

(...) : used to limit the scope ( with assertions captures the result )

(?:...) : without capture

Assertions

(?=...) : positive lookahead

(?!...) : negative lookahead

(?&lt;=...) : positive lookbehind

(?&lt;!...) : negative lookbehind

Generic classes

\n : new line

\r : carriage return

\t : tab

\b : word limit

\B : not a word limit

\d : figure

\D : not a figure

\s : white space ( \t \r \n \f )

\S : not a white space

\w : word

\W : not a word