在C#中,您可以只匹配所有(...)
子字符串,然后使用索引1访问第二个子字符串:
var rx = @"\([^)]*\)";
var matches = Regex.Matches(str, rx).Cast<Match>().Select(p => p.Value).ToList();
var result = matches != null && matches.Count > 1 ? matches[1] : string.Empty;
正则表达式匹配
\(
-开幕 (
[^)]*
-0个或多个其他字符 )
\)
-闭幕)
。本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句