首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于 "正则" 的小疑点。求解答

2013-08-10 
关于 正则 的小问题。求解答[解决办法]CODE(?code[^]+)/CODE.*DES(?des[\s\S]*?)/DES[解决

关于 "正则" 的小问题。求解答


[解决办法]
<CODE>(?<code>[^<>]+)</CODE>.*<DES>(?<des>[\s\S]*?)</DES>


[解决办法]

public static string[] GetHtmlImageUrlList(string sHtmlText)
{
string pattern = "(?is)<CODE>(?<code>.*?)</CODE>.*?<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;
}

热点排行