查找括号之间的所有字符与.NET正则表达式 [英] Finding All Characters Between Parentheses with a .NET Regex

查看:127
本文介绍了查找括号之间的所有字符与.NET正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的'('和')'字符的所有字符。

I need to get all characters between '(' and ')' chars.

   var str = "dfgdgdfg (aaa.bbb) sfd (c) fdsdfg (   ,ddd   (eee) )";

在这个例子中,我需要3字符串:

In this example, I need to get 3 strings:

(aaa.bbb)
(c)
(    ,ddd   (eee) )

我有什么模式来写?请帮助。

What pattern I have to write? Please, help.

推荐答案

尝试是这样的:

\(([^)] +)\)

编辑:其实这样做的非常的最后一些工作 - 这EX pression没有捕捉到最后一个子正常。我已经CW'd这个答案,这样的人有更多的时间可以人肉出来,使其正常工作。

Actually this does quite work for the last bit - this expression doesn't capture the last substring properly. I have CW'd this answer so that someone with more time can flesh it out to make it work properly.

这篇关于查找括号之间的所有字符与.NET正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆