Isolate SQL field using regex
Posted
by Das123
on Stack Overflow
See other posts from Stack Overflow
or by Das123
Published on 2010-04-01T22:27:06Z
Indexed on
2010/04/01
22:33 UTC
Read the original article
Hit count: 535
I'm trying to isolate a specific field in a SQL dump file so I can edit it but I'm not having any luck.
The regex I'm using is:
^(?:(?:'[^\r\n']*'|[^,\r\n]*),){6}('[^\r\n']*'|[^,\r\n]*)
Which is supposed to grab the seventh field and place it inside reference 1.
The trouble is that this is stumbling when ever it finds a comma inside a text field and counts the partial match as the allowable matches.
Eg. (1, 'Title', 1, 3, '2006-09-29', 'Commas, the bane of my regex', 'This is the target', 2, 4) matches " the bane of my regex'" instead of "'This is the target'".
© Stack Overflow or respective owner