C#正则Match的使用
发布时间:2015/1/30 10:09:59 作者:Admin 阅读:341
广告:
asp.net和C#正则Match的使用
Regex imgreg = new Regex(@"src=(.*)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
string img1 = "";
Match MV2 = imgreg.Match(html);
while (MV2.Success)
{
//hb.Append(MV.Groups[0]);
img1 = MV2.Groups[1].ToString().Trim();
if (img1 != "")
{
Uri addr2 = new Uri(relativeLocation, img1);
html = html.Replace(MV2.Groups[1].Value, addr2.AbsoluteUri); /*复杂替换方法*/
}
MV2 = MV2.NextMatch();
}
广告:
相关文章