Regular Expressions

Fortunately, PHP offers something more powerful than the strtok function: regular expressions. Written in a language of their own, regular expressions describe patterns that are compared to strings. The PHP source code includes an implementation of regular expressions that conform to the POSIX 1003.2 standard. This standard allows for expressions of an older style but encourages a modern style that I will describe. All the regular expression functions are described in Chapter 9.

In 1999, Andrei Zmievski added support for regular expressions that follow the style of Perl. They offer two advantages over PHP native regular expressions. They make it easier to copy an expression from a Perl script, and they take less time to execute. ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites 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.