13 Perl-Compatible Regular Expressions

Regular expressions are an amazingly powerful (but tedious) tool available in most of today’s programming languages and even in many applications. Think of regular expressions as an elaborate system of matching patterns. You first write the pattern and then use one of PHP’s built-in functions to apply the pattern to a value (regular expressions are applied to strings, even if that means a string with a numeric value). Whereas a string function could see if the name John is in some text, a regular expression could just as easily find John, Jon, and Jonathon.

PHP supports several types of regular expressions, the two most popular being POSIX Extended and Perl-Compatible (PCRE). In previous editions ...

Get PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.