我有matchCollection。 而且我需要组索引1. 现在我从大量的演员中提取数据,我想避免它。我怎样才能得到一个更简单的数据
示例:startTag = <a>
,endTag = </a>
Html = <a>texttexttext</a>
。
我需要得到 “texttexttext” 用了<a>
和</a>
var regex = new Regex(startTag + "(.*?)" + endTag, RegexOptions.IgnoreCase);
var matchCollection = regex.Matches(html);
foreach (var item in matchCollection)
{
string temp = ((Match)(((Group)(item)).Captures.SyncRoot)).Groups[1].Value;
}
你知道正则表达式和HTML/XML是坏朋友吗? –
@Marc Gravell,为什么?我不知道如何去 – Mediator
为什么在这里使用SyncRoot? –