【发布时间】:2023-03-18 20:09:01
【问题描述】:
我在下面有一段代码,我试图用它来匹配中间可以更改的字符串的开头和结尾。我首先尝试让这个示例正常工作,有人可以告诉我此代码的错误以及为什么它根本不匹配。
string pattern = @"/\/>[^<]*abc/";
string text = @"<foo/> hello first abc hello second abc <bar/> hello third abc";
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
Match m = r.Match(text);
【问题讨论】:
-
你想捕捉什么?我不确定我是否从您提供的正则表达式中得到它。另外,必填don't parse xml/html with regex
-
请不要立即开始新问题,我已经在您原来的问题中回答了您的问题。
标签: c# regex pattern-matching string-matching