之间的匹配字符串

之间的匹配字符串

本文介绍了VB.NET括号(括号)之间的匹配字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找用于在方括号之间匹配文本的模式.例如:"(this is) a (test)"应该输出

Looking for a pattern for matching text between brackets.For example: "(this is) a (test)" should output

"this is"
"test"

使用Dim m As Match = Regex.Match(str, pattern, RegexOptions.Multiline)

我搜索过stackOverflow,Google并在RegExr上尝试过示例,但似乎没有任何用处.

I have searched stackOverflow, Google and tried examples on RegExr and nothing seems to work for me.

这些可以在RegExr上工作,但不能在VB.NET中工作

These work on RegExr but in not VB.NET

"\(([^)(]++|(?R))+\)"-错误嵌套量词

"(?<=\<p\>)(.*?)(?=<\/p\>)"-不加修饰符的量词

其他人将返回:"this is) a (test"-匹配远方括号

Others will return:"this is) a (test" - matching far outer brackets

我也可以为

[],"",{}

对于在vb.net下看的人来说,将它们全部放在一个地方会很好

it would be good to have them all in one place for anyone looking under vb.net

推荐答案

\((.*?)\)

您的正则表达式非常复杂!这将抓取两个()之间的所有文本并匹配内部文本. 在此处播放.

Your regex is very complicated! This one will grab all text in between two () and match the inner text. Play with it here.

这篇关于VB.NET括号(括号)之间的匹配字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 11:09