Say I have a string like this, where items are separated by commas but there may also be commas within items that have parenthesized content:
(EDIT: Sorry, forgot to mention that some items may not have parenthesized content)
"Water, Titanium Dioxide (CI 77897), Black 2 (CI 77266), Iron Oxides (CI 77491, 77492, 77499), Ultramarines (CI 77007)"
How can I split the string by only those commas that are NOT within parentheses? i.e:
["Water", "Titanium Dioxide (CI 77897)", "Black 2 (CI 77266)", "Iron Oxides (CI 77491, 77492, 77499)", "Ultramarines (CI 77007)"]
I think I'd have to use a regex, perhaps something like this:
([(]?)(.*?)([)]?)(,|$)
but I'm still trying to make it work.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…