Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<IntroductionMeta-characters>
^PCRE regex syntaxLast updated: Mon, 26 Oct 2026

Delimiters

When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-NUL, non-whitespace single-byte character. Leading whitespace before a valid delimiter is silently ignored.

Note:

Multi-byte characters (such as UTF-8 encoded characters like ยง) cannot be used as delimiters. PHP reads exactly one byte as the delimiter; using a multi-byte character would cause the remaining bytes to be misinterpreted as unknown pattern modifiers.

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~). The following are all examples of valid delimited patterns.

/foo bar/
#^[^0-9]$#
+php+
%[a-zA-Z0-9_-]%

It is also possible to use bracket style delimiters where the opening and closing brackets are the starting and ending delimiter, respectively. (), {}, [] and <> are all valid bracket style delimiter pairs.

(this [is] a (pattern))
{this [is] a (pattern)}
[this [is] a (pattern)]
<this [is] a (pattern)>
Bracket style delimiters do not need to be escaped when they are used as meta characters within the pattern, but as with other delimiters they must be escaped when they are used as literal characters.

If the delimiter needs to be matched inside the pattern it must be escaped using a backslash. If the delimiter appears often inside the pattern, it is a good idea to choose another delimiter in order to increase readability.

/http:\/\//
#http://#
The preg_quote() function may be used to escape a string for injection into a pattern and its optional second parameter may be used to specify the delimiter to be escaped.

You may add pattern modifiers after the ending delimiter. The following is an example of case-insensitive matching:

#[a-z]#i


<IntroductionMeta-characters>
^PCRE regex syntaxLast updated: Mon, 26 Oct 2026