Hi folx,
Imagine a standard SQL INSERT statement:
INSERT INTO news SET id=1, abstract='Just a little test, nothing fancy', factor=+53.465, content='Here's the real sucker, a nested SQL statement: INSERT INTO news SET id=5, adminid=6, abstract=\'another test\'. Yeah, let\'s see who get\'s it...';
What I need to do is to parse the fields and their assigned values. After I wasted several hours trying to find the one-matches-all regexp I have decided to cut the "INSERT INTO x SET " off and then parse the remaining string from left to right.
For finding fieldnames I use:
/([a-zA-Z0-9_]*)[\s]?\=/
(this works)
For finding numbers (int|float) I use:
/((-|+|)([0-9]+)(.|)([0-9]+|))(,|😉[\s]?/
(working as well)
But how the heck am I going to create a pattern that matches everything between '' and only until the first comma or semicolon outside of the ''s appears? Note that inline 's will be escaped.
Right now I'm using this:
/\'(.*)\'(,|😉[\s]?/
But it's by far too greedy, doesn't gain me anything.
Thanks for anything,
Dominique