static void Main(string[] args) { string atxet = @"<h3 style=‘color: blue‘> <img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM20151109041139.jpg‘ />32323<img alt=‘laugh‘ height=‘20‘ src=‘http://sp-dev01/_layouts/portal/CKEditor/plugins/smiley/images/teethsmile.gif‘ title=‘laugh‘ width=‘20‘ /><img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM20151109041139.jpg‘ /></h3> <hr /><p> <img src=‘http://sp-dev01/KBC/KMS/KnowledgeEditImage/searchForKM201511 09041139.jpg‘ />323343434</p>"; Regex reg = new Regex(@"http://([a-zA-Z0-9-/ _]+)+.(gif|png|jpg)", RegexOptions.IgnoreCase); MatchCollection matchs = reg.Matches(atxet); foreach (Match item in matchs) { if (item.Success) { Console.WriteLine(item.Value); //这里就是匹配到的项 } } Console.Read(); }
时间: 2024-10-25 15:40:54