9.3. Regular Expressions

Although regular expressions are very powerful, they are difficult to use, especially if you're new to them. So, instead of jumping on the functions that PHP supports for dealing with the regular expressions, we cover the pattern matching syntax first. If PCRE is enabled, the following should show up in phpinfo() output, as shown in Figure 9.3.

Figure 9.3. PCRE phpinfo() output.

9.3.1. Syntax

PCRE functions check whether a text string matches a pattern. The syntax of a pattern always has the following format:

<delimiter> <pattern> <delimiter> [<modifiers>]

The modifiers are optional. The delimiter ...

Get PHP 5 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.