日期:2014-05-17 浏览次数:20548 次
string html = @"<img width=""226"" height=""164"" alt=""caiyu"" width=""226"" height=""164"" alt=""caiyu"" src=""http://localhost:4677/UserDir/Images/3c7e9eec047148e9196b673998b898a5.jpg"" />应用开发测试<img alt="""" src=""http://localhost:4677/UserDir/Images/cebd0017aa6b743e4b90a70e.jpg"" />应用开发测试<a href=""http://localhost:4677/UserDir/Documents/f在区域自动气象站WEB平台中的应用(英文).pdf"">/UserDir/Documents/f在区域自动气象站WEB平台中的应用(英文).pdf</a>"; var regimg = new Regex(@"(?<=src\="").*?(?="")", RegexOptions.IgnoreCase); var reghref = new Regex(@"(?<=href\="").*?(?="")", RegexOptions.IgnoreCase); List<string> src = new List<string>(); List<string> href = new List<string>(); foreach (Match r in regimg.Matches(html)) { src.Add(r.Value); } foreach (Match r in reghref.Matches(html)) { href.Add(r.Value); }