|
Posted by Rik on 05/31/06 00:46
siromega@gmail.com wrote:
> push(@new, $+) while $text =~ m{
> "([^\"\\]*(?:\\.[^\"\\]*)*)",? # groups the phrase inside
> the quotes
> | ([^,]+),?
> | ,
> }gx;
>
> I cant figure out how to convert that piece of perl above into
> preg_match. I've copied the string and escaped all the appropriate
> charecters however it still wont divide the string show above
> properly...
>
> $str = "foo, bar, \"foo, bar\", bar";
> $re = "\"([^\\\"\\\\]*(?:\\\\.[^\\\"\\\\]*)*)\",?| ([^,]+),?| ,";
> if (preg_match($re, $str, $res)) {
> print_r($res);
> }
It's a bitch for sure, isn't the wonderfull function fgetcsv() maybe
applicable in this case?
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|