<p><img alt=”” src=”/UpFiles/images/96dda144ad345982c989209d0ff431adcbef84ba.jpg” style=”width: 268px; height: 362px;” /> 求大神 |
|
200分 |
static void RegexImage() { string html = @"<p><img alt="""" src=""/UpFiles/images/96dda144ad345982c989209d0ff431adcbef84ba.jpg"" style=""width: 268px; height: 362px;"" /> <img alt="""" src=""/UpFiles/images/96dda144ad345982c989209d0ff431adcbef84ba.jpg"" style=""width: 268px; height: 362px;"" /> <img alt="""" src=""/UpFiles/images/96dda144ad345982c989209d0ff431adcbef84ba.jpg"" style=""width: 268px; height: 362px;"" /></p>"; string patten = @"<img\s+.*?src=""([^""]*)""\s+style=""width:\s*([^;]*);\s*height:\s*([^;]*);""\s*/>"; Regex.Matches(html, patten).Cast<Match>().ToList().ForEach(x => { Console.WriteLine(string.Format("Src:{0} Width:{1} Height:{2}", x.Groups[1].Value, x.Groups[2].Value, x.Groups[3].Value)); }); } |
一会试试楼上的
|