Parse html via RegularExpression and place results in Array

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 />");
}

source

Comments are closed.