开发者

Regular expression to get text inside parenthesis

开发者 https://www.devze.com 2022-12-08 13:19 出处:网络
I going to admit that I am hopeless at writing regular expressions. So can anyone please offer assistance in writing an expression (in C#) that will match the following cases:

I going to admit that I am hopeless at writing regular expressions. So can anyone please offer assistance in writing an expression (in C#) that will match the following cases:

value(Plugin.Tests.Business.Services.Repositories.Maps.SomeTests+<>c__DisplayClass2).
value(Plugin.Tests.Business.Interfaces.SomeOtherClass+<开发者_JAVA技巧>c__DisplayClass3).

Ideally I'd like anything between the brackets to be matched. Thanks for your assistance.


Regex r = new Regex(@"^value\((.*)\)\.$");


I would suggest investing in a tool like RegexBuddy. Give it a free trial.


Assuming you don't have any parentheses inside the substring:

Regex re = new Regex(@"^value\([^\)]+\)\.$");
0

精彩评论

暂无评论...
验证码 换一张
取 消