NYCPHP Meetup

NYPHP.org

[nycphp-talk] [ OT ] - Best Beginners Regex Book

inforequest 1j0lkq002 at sneakemail.com
Mon Jun 20 23:34:22 EDT 2005


Joseph Crawford codebowl-at-gmail.com |nyphp dev/internal group use| wrote:

> Hey everyone,
>
> what's the best book on the market for a beginner looking to learn 
> regex to use with PHP ???


I agree that "Mastering"  is the definitive resource, but it is written 
by someone who is really a serious regex optimizer. Whenever I need to 
know why my own regular expressions that seems to work well actually 
sucks, I can count on that book to highlight it for me. It is really 
quite hard to imagine all of the special cases that are missed by 
regular expressions.

For a PHP programmer wanting to learn regex,  I would suggest first 
challenging every apparent need for regex. Plenty of times the regex 
solution is sub-optimal compared to a PHP native solution, and with so 
many native functions available in PHP these days there is less and less 
need for loading the regex engine. Sure there are plenty of times regex 
is the right solution -- but shouldn't a good php programmer know PHP 
well enough to do make that call only when necessary?

There are arguments in favor of a standardized notation for "regular 
sets" (i.e. regex) and of course it is handy to utilize one knowledge 
base for pattern matching with grep and vim/ex and perl as well as PHP,  
but if it is pattern search/match functionality that is needed in PHP 
code I think mastery of the PHP natives will get you over most hurdles. 
Maybe you'll have more readable code with fewer missed cases, and less 
dependence on the regex engine.

-=john andrews







More information about the talk mailing list