Chapter 29. Regular Expression Functions

Regular expressions (often shortened to just regex) are patterns that describe a set of strings. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions. They are a very powerful tool for matching or replacing text. PHP has a function-oriented interface to regular expressions, as opposed to Perl, where regular expressions are implemented at the language level. PHP supports two kinds of regular expressions out of the box: POSIX Extended and Perl-compatible. The functions for both are similar, but Perl-compatible expressions support many more options and are considered to be faster and more powerful in general.

Get PHP Functions Essential Reference 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.