O'Reilly logo

PHP 5 Recipes: A Problem-Solution Approach by Jon Stephens, Frank M. Kromann, Nathan A. Good, Lee Babin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9Using Regular Expressions

Sometimes when you are processing strings, you will run into a problem that is difficult to solve with strcomp or other functions. For instance, you might have to validate an e-mail address, which requires you to look at many difficult-to-check rules.

This is where regular expressions come in handy. Regular expressions are powerful, concise groups of characters that can contain quite a bit of logic, especially considering how short they are.

Think of regular expressions as mathematical expressions that work on strings. Like mathematical expressions, regular expressions have certain characters that mean something special. Like + says "plus" in a mathematical expression, a character such as ^ says "the beginning ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required