0 or more


Exactly 3


1 or more


3 or more


0 or 1


3, 4 or 5

Add a ? to a quantifier to make it ungreedy.




Start of string, or start of line in multi-line pattern


Start of string


End of string, or end of line in multi-line pattern


End of string


Word boundary


Not word boundary


Start of word


End of word




Lookahead assertion


Negative lookahead


Lookbehind assertion

?!= or ?<!

Negative lookbehind


Once-only Subexp­ression


Condition [if then]


Condition [if then else]




Groups and Ranges


Any character except new line (\n)


a or b




Passive (non-c­apt­uring) group


Range (a or b or c)


Not (a or b or c)


Lower case letter from a to q


Upper case letter from A to Q


Digit from 0 to 7


Group/­sub­pattern number "­x"

Ranges are inclusive.

Character Classes


Control character


White space


Not white space




Not digit




Not word


Hexade­cimal digit


Octal digit


Escape Sequences


Escape following character


Begin literal sequence


End literal sequence

"­Esc­api­ng" is a way of treating characters

which have a special meaning in regular

expres­sions literally, rather than as special charac­ters.


Pattern Modifiers


Global match

i *


m *

Multiple lines

s *

Treat string as single line

x *

Allow comments and whitespace in pattern

e *

Evaluate replac­ement

U *

Ungreedy pattern

* PCRE modifier


String Replac­ement


nth non-pa­ssive group


"­xyz­" in /^(abc­(xy­z))$/


"­xyz­" in /^(?:a­bc)­(xyz)$/


Before matched string


After matched string


Last matched string


Entire matched string

Some regex implem­ent­ations use \ instead of $.

Common Metach­ara­cters
















The escape character is usually \




Upper case letters


Lower case letters


All letters


Digits and letters




Hexade­cimal digits




Space and tab


Blank characters


Control characters


Printed characters


Printed characters and spaces


Digits, letters and underscore


Special Characters


New line


Carriage return




Vertical tab


Form feed


Octal character xxx


Hex character hh


Case Conversion


Make next character lowercase


Make next character uppercase


Make entire string (up to \E) lowercase


Make entire string (up to \E) uppercase


Capitalize first char, lowercase rest (sentence)

Source: davechild


Main Menu

Login Form