I have a string that I want to split into an array by using the commas as delimiters. I do not want the portions of the string that is between parentheses to be split though even if they contain commas.
For example:
"bibendum, morbi, non, quam (nec, dui, luctus), rutrum, nulla"
Should become:
["bibendum", "morbi", "non", "quam (nec, dui, luctus)", "rutrum", "nulla"]
But when I use a basic .split(",")
, it returns:
["bibendum", " morbi", " non", " quam (nec", " dui", " luctus)", " rutrum", " nulla"]
I need it to return:
["bibendum", " morbi", " non", " quam (nec, dui, luctus)", " rutrum", " nulla"]
Your help is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…