News Feed
Sections
News Archive


Community Events
php|tek 2008 PHP Conference



feed this:

SitePoint PHP Blog:
Tokenization using regular expression sub patterns
0 comments :: posted Friday January 18, 2008 @ 11:15:49
voice your opinion now!

On the SitePoint PHP blog there's a new post from Harry Fuecks talking about a replacement method using token that works a bit better than the typical regular expression method.

Promtped by a real world example, one often-overlooked feature of most regular expressions engines is how subpatterns can useful to whip up tokenizers relatively easily. The problem? I needed to match the word any of the words "Canton", "Region" or "Group" in a string and perform a follow up action depending on which matched.

His ultimate solution used a set of preg_match generated tokens to do the replaces a bit more reliably. It also makes it easy for other scripts (like his Python example) to use them too.

tagged with: regularexpression pattern token replace



application code pecl releases PHP5 conference cakephp framework zend book database developer PEAR package release mysql ajax job security zendframework

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework