Pattern Matching with PHP

In my latest plugin, Custom Title Attributes, I needed to learn about Pattern Syntax to get what I needed working. To put this simply, I needed to replace one specific section of a string with another. Usually this would be easily done using the string replace function, however this only works if you know what string to search for in the first place.

With my plugin I had to match a pattern instead of a specific string to get what I needed. This can be achieved using a form of preg_replace() which was the preg_replace_callback() function. I'm not about to go into detail as to how these work just now. My point of this post was simply to mention the page (besides the PHP manual) that has really helped me out and explained things so clearly that I felt it deserved a mention and a thanks. So if you're interested in understanding pattern matching and regular expressions then I highly recommend reading WebCheatSheet's article – Using Regular Expressions with PHP.

One Response to “Pattern Matching with PHP”

Trackbacks/Pingbacks

  1. Mod Rewrite Fun and Games :: Stuff by Sarah
Leave a Comment

Please use your real name or nickname. Spam names will be changed.