Regular Expressions (Perl-Compatible)
Introduction
The syntax for patterns used in these functions closely resembles Perl. The expression must be enclosed in the delimiters, a forward slash (/), for example. Delimiters can be any non-alphanumeric, non-whitespace ASCII character except the backslash (\) and the null byte. If the delimiter character has to be used in the expression itself, it needs to be escaped by backslash. Perl-style (), {}, [], and <> matching delimiters may also be used. See Pattern Syntax for detailed explanation.
The ending delimiter may be followed by various modifiers that affect the matching. See Pattern Modifiers.
Note:
This extension maintains a global per-thread cache of compiled regular expressions (up to 4096).
You should be aware of some limitations of PCRE. Read » http://www.pcre.org/pcre.txt for more info.
The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5, with just a few differences (see below). The current implementation corresponds to Perl 5.005.
- Installing/Configuring
- Predefined Constants
- Examples
- PCRE Patterns
- PCRE regex syntax — Pattern Syntax
- Possible modifiers in regex patterns — Pattern Modifiers
- Differences From Perl — Perl Differences
- PCRE Functions
- preg_filter — Perform a regular expression search and replace
- preg_grep — Return array entries that match the pattern
- preg_last_error — Returns the error code of the last PCRE regex execution
- preg_last_error_msg — Returns the error message of the last PCRE regex execution
- preg_match — Perform a regular expression match
- preg_match_all — Perform a global regular expression match
- preg_quote — Quote regular expression characters
- preg_replace — Perform a regular expression search and replace
- preg_replace_callback — Perform a regular expression search and replace using a callback
- preg_replace_callback_array — Perform a regular expression search and replace using callbacks
- preg_split — Split string by a regular expression