Chapter 15. Regular ExpressionsRegular expressions, usually referred to as regexps, offer you more power over your strings, but are tricky to learn because they use complicated syntax. Regexps can:
We'll be looking at all three of these uses in this chapter, as well as providing a comprehensive list of the different expressions you can use to work with all kinds of strings. You should know that the set of string functions covered in Chapter 7 are faster, easier to read, and less hassle to use than regular expressions; you should only use regular expressions if you have a particular need. PHP contains two ways to perform regular expressions, known as POSIX-extended and Perl-Compatible Regular Expressions (PCRE). The PCRE functions are more powerful than the POSIX ones, and faster too, so we will be using the PCRE functions here. |