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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux