> -----Original Message----- > From: Jim Lucas [mailto:lists@xxxxxxxxx] > Sent: Thursday, November 06, 2008 9:58 AM > To: tgol@xxxxxxxxxx > Cc: php-general@xxxxxxxxxxxxx > Subject: Re: removing text from a string > > Thodoris wrote: > > > >> Ashley Sheridan a écrit : > >> > >>> Thats a lot of code when a couple of lines and a regex will do ;) > >> > >> Maybe because the use of the regex is pointless here. A bazooka to > >> kill the fly ? :) > >> > > > > I couldn't agree more. Not to mention that they are probably slower. > > > > PS Don't get me wrong I like perl and pcre but it is pointless here. > > > > Personal choice, and yes my testing has proven that a regex is faster > then the multiple function calls or if conditions needed to accomplish > the same > thing. Yeah, I think people under-estimate the performance of (SIMPLE) Regular Expressions for text manipulation and searching. As long as you don't have like 15 nested groups and callbacks and optional chars/groups out the wazoo in your PCRE pattern, it will be very quick: it was designed with efficiency and speed in mind. I feel it's also worth mentioning that it may be worthwhile to lean towards RegEx functions for text searching/manipulation so that there is a consistency between methods throughout your code. 15 regex patterns may be better than intermingling xtrim(), strstr(), stripos(), str_replace(), etc... and are probably more easily-readable than scanning 15 10-line algorithms to discern their purpose. Just a thought. Todd Boyd Web Programmer RegEx Fan (but not Fanatic) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php