Re: Regular Expression just one step away from what I need....

From: Date: Fri, 17 Aug 2007 17:30:37 +0000
Subject: Re: Regular Expression just one step away from what I need....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-260975@lists.php.net to get a copy of this message
On Fri, 2007-08-17 at 12:00 -0500, Jay Blanchard wrote: > Given the string 'foo''bar''glorp' (all quotes are single > quotes)I had > hoped to find a regular expression using preg_match that would return an > array containing just those words without having to go through > additional gyrations, like exploding a string to get an array. I have > only had limited luck > > $theString = "'foo''bar''glorp'"; > preg_match( "/\'(.*)\'/", $theString, $matches); > print_r($matches); You want to add the ungreedy modifier... preg_match( "/\'(.*)\'/U", $theString, $matches); Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ...........................................................

« previous php.general (#260975) next »