On Mon, 2005-05-02 at 16:08 +0100, Alan Chandler wrote:
--snip--
> For instance I want the parse this string
>
> Form = 'This is a bad bad thing, but not as bad as it would be if \"x = 5\",
> so thats it',Connection=5
>
> Into the strings
>
> Form
>
> =
>
> 'This is a bad bad thing, but not as bad as it would be if \"x=5\", so thats
> it'
>
> ,
>
> Connection
>
> =
>
> 5
>
> using the php preg_split() finction. So, I first want to find a regex that
> finds the commas I have split out (bit not the common in the quoted string,
> and then for each substring put that through another version of preg_split()
> which finds the = as delimeters. Again in the quoted string, I want to
> ignore the x=5 equal sign.
Something like this should do the trick:
/('.*?')*?,('.*?')*/
If you KNOW that the commas are going to be before or after the quoted
string, then the above could be simplified a bit.
Disclaimer: The above is written from the top of my head. I don't have a
chance to test it at the moment so YMMV.
--
Alex Malinovich
Support Free Software, delete your Windows partition TODAY!
Encrypted mail preferred. You can get my public key from any of the
pgp.net keyservers. Key ID: A6D24837
Attachment:
signature.asc
Description: This is a digitally signed message part