/ Published in: C#
In this case I'm looking for image sources in html and placing them in array.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System.Text.RegularExpressions; //looking for photo paths with REGX-a string nl = // in this case page html. MatchCollection mc = null; string sRegExp = "src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?"; mc = Regex.Matches(nl, sRegExp); string[] path; for (int j = 0; j < mc.Count; j++) { path = mc[j].Value.Split('"'); Response.Write(path[1].ToString().Trim() + "<br />"); }