Pattern (start and end slashes will be added when needed)

Replacement

Subject

Matches

Code

Result

preg_match_all

preg_match

preg_replace

preg_split


Caseless (i)

Multiline mode (m)

Dot all (s)

Extended (x)

Anchored (A)

Dollar end only (D)

Extra analysis of pattern (S)

Pattern is ungreedy (U)

Extra (X)

Pattern is treated as UTF-8 (u)


Pattern order

Set order

Offset capture

Split no empty

Split delim capture

Split offset capture


Offset

Limit

Help PHP PCRE
.
Any character
^
Start of subject (or line in multiline mode)
$
End of subject (or line in multiline mode)
[
Start character class definition
]
End character class definition
|
Alternates (OR)
(
Start subpattern
)
End subpattern
\
Escape character
\n
Newline (hex 0A)
\r
Carriage return (hex 0D)
\t
Tab (hex 09)
\d
Decimal digit
\D
Charchater that is not a decimal digit
\h
Horizontal whitespace character
\H
Character that is not a horizontal whitespace character
\s
Whitespace character
\S
Character that is not a whitespace character
\v
Vertical whitespace character
\V
Character that is not a vertical whitespace character
\w
"Word" character
\W
"Non-word" character
\b
Word boundary
\B
Not a word boundary
\A
Start of subject (independent of multiline mode)
\Z
End of subject or newline at end (independent of multiline mode)
\z
End of subject (independent of multiline mode)
\G
First matching position in subject
n*
Zero or more of n
n+
One or more of n
n?
Zero or one occurrences of n
{n}
n occurrences
{n,}
At least n occurrences
{,m}
At the most m occurrences
{n,m}
Between n and m occurrences