在正则表达式模式使用圆括号 [英] Using parenthesis in Regular Expressions pattern
本文介绍了在正则表达式模式使用圆括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串这段文字有一些(括号内文字)。所以我想检索使用正则表达式在C#中括号内的文字。但括号已经在正则表达式保留字符。那么如何得到它?
I've a string "This text has some (text inside parenthesis)". So i want to retrieve the text inside the parenthesis using Regular Expressions in C#. But parenthesis is already a reserved character in regular expressions. So how to get it?
更新1
所以文< STRONG>afasdfas(2009)
我试过()/ S((/ D +))
和()(\d +)
和(。*)/ S((/ D / D / D / D))
。他们没有工作。任何想法?
I tried (.)/s((/d+))
and (.) (\d+)
and (.*)/s((/d/d/d/d))
. None of them is working. Any ideas?
推荐答案
您可以用反斜杠或的 Regex.Escape()。
这篇关于在正则表达式模式使用圆括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文