PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

PHPBuilder.com: 10 Easy Examples for Deciphering PHP Regular Expressions

Note: This article was originally published at PHPDeveloper on 22 July 2010.
PHPDeveloper

On PHPBuilder.com today Jason Gilmore has posted ten easy regular expression tips that can help you understand the matching on some of the common pieces of data your app might come across.

Regular expressions are the PHP programmer's equivalent of being audited by the IRS. The mere thought of an encounter is enough to cause heart palpitations. [...] If you would like to decipher the melange of backslashes, brackets, asterisks and other characters somehow capable of rooting out everything from email addresses to HTML tags, follow along with this tutorial which introduces the topic using 10 numerically-oriented examples.

He starts simple - finding digits - and progresses into matching groups, filtering strings, using more complex patterns, correcting errors you might find in the data and a note that, despite their power, you don't always need them. There could be a simpler way.