Regular Expressions

Regular expressions are an amazingly powerful but tedious tool available in most of today’s programming languages. Think of regular expressions as an elaborate system of matching patterns. You first write the pattern, then use one of PHP’s built-in functions to apply the pattern to a text string (regular expressions are specifically for use with strings).

PHP has two functions for using regular expressions to match patterns (one casesensitive and one not) and two for matching patterns and replacing matched text with other text (again, one case-sensitive and one not). Further, PHP supports two types of regular expressions: POSIX Extended and Perl-compatible (PCRE). The POSIX version is somewhat less powerful and potentially ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide 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.