html

Regular Expression Cheat Sheet

Matching the Basics

. Matches any character.

^ Matches start of line.

$ Matches end of line.

*<\|> Matches 0 or more of the preceding element.

+ Matches 1 or more of the preceding element.

? Matches 0 or 1 of the preceding element.

+ Matches 1 or more of the preceding element.

! Matches any character that is NOT in the preceding class.

^ Matches any character that is NOT in the preceding class.

- Matches a hyphen.

[ Matches an opening bracket.

] Matches a closing bracket.

{ Matches an opening curly bracket.

} Matches a closing curly bracket.

| Matches a vertical bar or pipe.

\ Matches an escape character.

. Matches a period.

\ Matches a backslash.

/ Matches a forward slash.

\n Matches a line feed.

\t Matches a tab.

\r Matches a carriage return.

\b Matches a word boundary.

\B Matches a non-word boundary.

\d Matches any digit.

\D Matches any non-digit.

\w Matches any word character.

\W Matches any non-word character.

[a-z] Matches any lowercase letter "a" or "z".

A-Z Matches any uppercase letter "A" or "Z".

[0-9] Matches any digit "0" or "9".

[a-z] Matches any lowercase letter.

[A-Z] Matches any uppercase letter.

[0-9] Matches any digit.

[0-9a-zA-Z] Matches any digit or letter.