简体   繁体   English

正则表达式帮助asp.net c#

[英]Regex help in asp.net c#

I have a large string that may have some items I want to retrieve out of it. 我有一个大字符串,可能有一些我想从中检索出来的项目。

An example string could be 一个示例字符串可能是

"The quick |Get Me|(header1) brown fox |Get Me|(info package) jumps over ..."

I would like a regex to extract what is in between the brackets, not including the brackets and the brackets will always follow "|Get Me|" 我想要一个正则表达式来提取括号之间的内容,不包括括号和括号将始终跟随"|Get Me|"

A pattern that will match: 一个匹配的模式:

\|Get Me\|\(([^)]+)\)

Usage: 用法:

var matches = Regex.Matches(myString, @"\|Get Me\|\(([^)]+)\)");

foreach(Match match in matches)
{
   var val = match.Groups[1].Value;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM