[英]regexp, Extract value between parentheses
example:例子:
"today [(["hi"],{"my"})],["ok"],("good")),(["gg"],["fire"])] nice game [(["1"],{"2"})],["3"],("4")),(["5"],["6"])] end."
-> ->
[(["hi"],{"my"})],["ok"],("good")),(["gg"],["fire"])]
[(["1"],{"2"})],["3"],("4")),(["5"],["6"])]
In this case, there is a noise in the middle.
在这种情况下,中间有噪音。
It doesn't work in the usual way它不能以通常的方式工作
Please give me an idea of extracting the value between parentheses in another way请给我一个想法,以另一种方式提取括号之间的值
I love regex, almost as much as I hate them.我喜欢正则表达式,几乎和讨厌它们一样多。 Writing an effective regex can take a problem from impossible to trivial.
编写有效的正则表达式可以使问题变得微不足道。
Knowing how to iterate one is very important.知道如何迭代一个是非常重要的。 Let me teach a man to fish.
让我教一个人钓鱼。
Consider using an online regex tool: https://regex101.com/考虑使用在线正则表达式工具: https://regex101.com/
Input your string:输入你的字符串:
image of me adding in the text我在文本中添加的图像
Then try to Match it.然后尝试匹配它。 I did with the following
\([^()]+\)
我做了以下
\([^()]+\)
That is:那是:
\(
and \)
because they are special symbols.\(
和\)
上匹配的括号,因为它们是特殊符号。[^...]
where the elipsis are all the characters I don't want to match.[^...]
使用不匹配子句,其中省略号是我不想匹配的所有字符。 I then add my parenthesis raw in there [^()]
[^()]
+
.+
。 Thus I have my awnser.这样我就有了我的遮阳篷。
image of me matching the text我与文本匹配的图像
edit: cannot post images because of rep编辑:由于代表无法发布图片
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.