R
Robert Dodier
Hello,
I'd like to split a string by commas, but only at the "top level" so
to speak. An element can be a comma-less substring, or a
quoted string, or a substring which looks like a function call.
If some element contains commas, I don't want to split it.
Examples:
'foo, bar, baz' => 'foo' 'bar' 'baz'
'foo, "bar, baz", blurf' => 'foo' 'bar, baz' 'blurf'
'foo, bar(baz, blurf), mumble' => 'foo' 'bar(baz, blurf)' 'mumble'
Can someone suggest a suitable regular expression or other
method to split such strings?
Thank you very much for your help.
Robert
I'd like to split a string by commas, but only at the "top level" so
to speak. An element can be a comma-less substring, or a
quoted string, or a substring which looks like a function call.
If some element contains commas, I don't want to split it.
Examples:
'foo, bar, baz' => 'foo' 'bar' 'baz'
'foo, "bar, baz", blurf' => 'foo' 'bar, baz' 'blurf'
'foo, bar(baz, blurf), mumble' => 'foo' 'bar(baz, blurf)' 'mumble'
Can someone suggest a suitable regular expression or other
method to split such strings?
Thank you very much for your help.
Robert