CSharp examples for System:String HTML
Get Img Url Array from html string using regex
using System.Text.RegularExpressions; using System.Text; using System.Net; using System.IO;/*from ww w. j a v a 2 s . c om*/ using System.Collections.Generic; using System; public class Main{ /// <summary> /// ??????code?????????? /// </summary> /// <returns>????????????????</returns> public static Dictionary<string, string> GetImgUrlArray(string content) { var imgList = new Dictionary<string, string>(); var reg = new Regex(@"<img[\s\S]*?src=(""(?<src>[^']*?)""|'(?<src>[^']*?)'|(?<src>[^>\s]*))[^>]*?>(.*?)"); MatchCollection m = reg.Matches(content.ToLower()); foreach (Match match in m) { string matchValue = match.Groups["src"].Value; if (!imgList.ContainsKey(matchValue)) { imgList.Add(matchValue, matchValue); } } return imgList; } }