Приглашаем посетить
Набоков (nabokov-lit.ru)

Chapter 15.  Regular Expressions

Previous
Table of Contents
Next

Chapter 15. Regular Expressions

Regular 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:

  • Replace text

  • Test for a pattern within a string

  • Extract a substring from within a string

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.


Previous
Table of Contents
Next