Hi,
I need some help to split data using regular expression
Consider the string
'1,2,3', I can split it using, preg_split("/,/", '1,2,3') and i correctly
get [0]=1, [1]=2,[2]=3.
Now if i have
'1,"2,3"' i could split it using preg_split("/(?<!\"),/\d", '1,"2,3"') and i
correctly get [0]=1, [1]="2,3".
But it clearly does not work in some more advanced cases, for example
'1," 2 , 3"' or '1,"2 , 3 "' mainly because the /d is no longer useful.
So how can i search for a regular expression that is *not within*
apostrophes?
I think i might have to write my own split function especially if i have an
extreme case like, '1," 2 , \" 3"', (note the escape apostrophe).
Many thanks for you input.
Sims
I need some help to split data using regular expression
Consider the string
'1,2,3', I can split it using, preg_split("/,/", '1,2,3') and i correctly
get [0]=1, [1]=2,[2]=3.
Now if i have
'1,"2,3"' i could split it using preg_split("/(?<!\"),/\d", '1,"2,3"') and i
correctly get [0]=1, [1]="2,3".
But it clearly does not work in some more advanced cases, for example
'1," 2 , 3"' or '1,"2 , 3 "' mainly because the /d is no longer useful.
So how can i search for a regular expression that is *not within*
apostrophes?
I think i might have to write my own split function especially if i have an
extreme case like, '1," 2 , \" 3"', (note the escape apostrophe).
Many thanks for you input.
Sims
Comment