110,537
社区成员
发帖
与我相关
我的任务
分享
Regex token = new Regex(@"(?<word>abc)", RegexOptions.Compiled);
MatchCollection matches = token.Matches("bcabcabcabcabcpp");
if (matches.Count != 0)
{
foreach (Match matchList in matches)
{
Console.WriteLine("word:{0}",matchList.Groups["word"]);
}
}
Console.ReadLine();
string str = "bcabcabcabcabcpp";
Console.WriteLine(Regex.Match(str, @"(?<!abc)(?<word>abc)").Groups["word"].Value);