Re: preg_match and delimited strings
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Wed, 31 May 2006 02:46:12 +0200
siromega@xxxxxxxxx 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
.
- Follow-Ups:
- Re: preg_match and delimited strings
- From: siromega
- Re: preg_match and delimited strings
- References:
- preg_match and delimited strings
- From: siromega
- preg_match and delimited strings
- Prev by Date: How to plug in a variable for BCMath?
- Next by Date: Re: How to plug in a variable for BCMath?
- Previous by thread: preg_match and delimited strings
- Next by thread: Re: preg_match and delimited strings
- Index(es):
Relevant Pages
|