日期:2014-05-17 浏览次数:21331 次
//为什么匹配不出来?对正则不太熟,想问下原因,以及如何修改
//sHtmlText的内容 :<CODE>2005</CODE><DES>listing product to trademe error:You can't have more than 10 custom shipping options.\r\n</DES>\r\n
public static string[] GetHtmlImageUrlList(string sHtmlText)
{
string pattern = "<CODE>(?<code>[^<>]+)</CODE>.*<DES>(?<des>.*)</DES>";
//string pattern1 = "<DES>(?<des>.*)</DES>";
Regex regImg = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection matches = regImg.Matches(sHtmlText); //搜索匹配的字符串
string[] result = new string[2];
foreach (Match match in matches)
{
result[0] = match.Groups["code"].Value.ToString();
result[1] = match.Groups["des"].Value.ToString();
}
return result;
}