0
您好我有很多的HTML文件,我需要從中提取一些信息,例如,提取設備型號,我用下面的正則表達式代碼:淨正則表達式來提取文本
string sFullString = "Device:</span> <span id=\"model-value\" category=\"model\">DXE-9880</span></li>";
string sStart = "category=\"model\">";
string sEnd = "<";
Regex regex = new Regex("(?<=" + Regex.Escape(sStart) + @").*(?=" + Regex.Escape(sEnd) + @")", RegexOptions.IgnoreCase);
Match match = regex.Match(sFullString);
if (match.Success)
{
Console.WriteLine(match.Value);
}
預期結果爲「DXE-9880」,但始終爲「DXE-9880 </span >」。 爲什麼第二個「<」在型號後面找到,而不是第一個?