Hour 18. Working with Regular Expressions

What You’ll Learn in This Hour:

  • How to match patterns in strings using regular expressions

  • The basics of regular expression syntax

  • How to replace text in strings using regular expressions

  • How to use regular expressions to split a string into an array

Regular expressions are a powerful way of examining and modifying text. They enable you to search for patterns within a string, extracting matches flexibly and precisely. Be warned that because they are more powerful, they are also slower than the more basic string function examined in Hour 8, “Working with Strings.” You should use string functions, therefore, if you don’t need the extra power afforded by the use of a regular expression function.

PHP supports ...

Get Sams Teach Yourself PHP in 24 Hours, Third 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.