Reputation: 929
I have a string like hello, "darkness, my", (old, friend)
and I want this splitted result:
hello
"darkness, my"
(old, friend)
I found a way to ignore the commas in "-marks (,?=([^\"]*\"[^\"]*\")*[^\"]*$
) and another way to ignore the commas in brackets (,(?=[^\\)]*(?:\\(|$))
).
When I use the first, I get:
hello
"darkness, my"
(old
friend)
And when I use the second, I get:
hello
"darkness
my"
(old, friend)
But how do I combine these two solutions?
Upvotes: 5
Views: 7818
Reputation: 2152
Probably easier to match the parts, rather than splitting them.
This will capture each piece of data as group 1.
Upvotes: 3