Chapter 8. Regular Expressions

In this lesson you will learn about advanced string manipulation using regular expressions. You will see how to use regular expressions to validate a string and to perform a search-and-replace operation.

Introducing Regular Expressions

Using regular expressions—sometimes known as regex—is a powerful and concise way of writing a rule that identifies a particular string format. Because they can express quite complex rules in only a few characters, if you have not come across them before, regular expressions can look very confusing indeed.

At its very simplest, a regular expression can be just a character string, where the expression matches any string that contains those characters in sequence. At a more advanced ...

Get Sams Teach Yourself PHP in 10 Minutes 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.