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 and then use one of PHP’s built-in functions to apply the pattern to a text string (regular expressions are normally used with strings).
PHP supports two types of regular expressions: POSIX Extended and Perl-compatible (PCRE). The POSIX version is somewhat less powerful and potentially slower than PCRE but is far easier to learn. For this reason, I’ll cover POSIX regular expressions here.
With both types of regular expressions, PHP has two functions for simple pattern matches (one case-sensitive and one not) ...
Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition 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.