【发布时间】:2016-08-03 15:26:00
【问题描述】:
我有一个长字符串,只要逗号不在方括号或圆括号内,我想通过用逗号分割它来将它设置为一个数组。我尝试了几种变体,但没有得到我想要的……
示例 1:
Harry Potter, Hermione, (Severus, Snape)
Returns:
Harry Potter
Hermione
Severus, Snape
示例 2:
Harry Potter, [and, the chamber, of secrets], Hermione, (Olivanders, Wands)
Returns:
Harry Potter
and, the chamber, of secrets
Hermione
Olivanders, Wands
【问题讨论】:
-
@Marc - 我看到了这个问题,但我仍然不清楚如何解释我正在寻找的这两个条件。
-
重新打开,因为这个问题是关于括号和括号:完整的答案更难。
-
@Bathsheba stackoverflow.com/questions/28587081/…
-
不错的地方,但恕我直言,值得特别回答一下,尽管您找到的答案可能足以满足 OP。