Page 1 of 1

multiple delimiters

Posted: Wed Mar 25, 2009 11:25 pm
by obfusc88
This is a typical sample line showing sometimes a comma/space as delimiter, sometimes in double quotes, not always. Different patterns may change position on each line.

Sample line:
"this is a good piece" "abc" , "5" "66",7

Looking to get these values selected from the line:
1= "this is a good piece"
2= "abc"
3= "5"
4= "66"
5= 7

Maybe it needs multiple RegEx passes vs. 1? Maybe put spaces around the commas, then select everything separated by (spaces that are not inside double quotes)?

Want to do a RegEx to select all of these values. Can this be done using different RegEx separated with "|" ?
Can this be done to take everything inside double quotes and everything between comma/space if not inside double quotes?

Can this be done with normal Perl RegEx syntax vs. TextPad syntax? If I see a working Perl version, I may be able to work with that. How to look for all between double quotes, but not greedy, so the first value is selected vs. most of the entire line?

I have tried various RegEx things like these, but none came close:
".*"[?= ]
^.*[^ "]?[?= ]
^.*[^ "][?= ]|".*"[?= ]
".*[^,]
"[\w+]|[\w+\s*\w+]"

Posted: Thu Mar 26, 2009 8:35 am
by ben_josephs
([^ ,]+|"[^"]*")[ ,]+([^ ,]+|"[^"]*")[ ,]+([^ ,]+|"[^"]*")[ ,]+([^ ,]+|"[^"]*")[ ,]+([^ ,]+|"[^"]*")