由网友(举悲到凌尘ゅ)分享简介:输入是一个逗号分隔的字段列表。 下面是一个例子。TNA,性能,MA [性能,3,价格问题是,一些字段都在方括号中指定参数,这些参数也有逗号。 正则表达式是什么我能使用,打破这样的字符串的逗号,只有当他们括号内。我想最终的结果是TNA性能马[演出,3]价格解决方案 这是你所需要的。(小于?!?\ [\ W,] *)...![初一数学精选10大易错题型 例题解析](https://p.xsw88.cn/allimgs/daicuo/20230904/6297.png)
输入是一个逗号分隔的字段列表。
下面是一个例子。
TNA,性能,MA [性能,3,价格
问题是,一些字段都在方括号中指定参数,这些参数也有逗号。
正则表达式是什么我能使用,打破这样的字符串的逗号,只有当他们括号内。我想最终的结果是
TNA
性能
马[演出,3]
价格
![初一数学精选10大易错题型 例题解析](https://p.xsw88.cn/allimgs/daicuo/20230904/6297.png)
解决方案
这是你所需要的。
(小于?!? [ W,] *),
如果是嵌套的括号内支架,使用这个,因为上面会在这情况下也会失败。
(小于?! [?[ W,] *)(?!?[ W,] * ])
这里
The input is a comma-separated list of fields.
Here is an example.
tna,performance,ma[performance,3],price
The issue is that some of the "fields" have parameters specified in square brackets and those parameters also have commas.
What RegEx could I use to break a string like that on commas, only when they are outside of brackets. I want the end result to be
tna
performance
ma[performance,3]
price
解决方案
This is what you need
(?<![[w,]*?),
If brackets are nested within brackets, use this because the above would fail in that scenario..
(?<![[w,]*?),(?![w,]*?])
works here
相关推荐
最新文章