正则表达式找到某些字符,但如果在某些模式之间则找不到

时间:2018-10-09 11:59:13

标签: javascript regex

我对需要提供的此regEx感到噩梦。这个想法基本上是在某个字符串中的括号之间找到所有的','字符...但是,如果在该括号内还有另一个包含','的括号,则不要包含它。

示例:

(hello, something, hi, (another, one), last)

所以想法是检测并匹配5个组

1. (hello,
2. something,
3. hi,
4. (another, one),
5. last)

我一直在努力,但我不能像这样分手,而是分成了6组

1. (hello,
2. something,
3. hi,
4. (another,  <-- not ok
5. one), <-- not ok
6. last)

一直在尝试使用regEx,但是我无法检测到double()模式,到目前为止,我能达到的最好成绩是

(?!\(.*)[,](?=.*\))

感谢您的时间和帮助

0 个答案:

没有答案
相关问题