格式如这样的:<img src="http://A/B/C" border="1" align="left" class="student" /></a>
想取到值C,其中A和B是固定的,就向时http://www.123.com/files/1.jpg,那么A就是http://www.123.com/,B就是files,c酒是1.jpg,也就是我想要的,请问这个正则怎么写,谢了!
想取到值C,其中A和B是固定的,就向时http://www.123.com/files/1.jpg,那么A就是http://www.123.com/,B就是files,c酒是1.jpg,也就是我想要的,请问这个正则怎么写,谢了!
Regex reg = new Regex(@"(?is)<img[^>]*?src=(['""\s]?)http://www.123.com/files/([^'""\s]+)\1[^>]*?>");
foreach (Match m in reg.Matches(str))
Console.WriteLine(m.Groups[2].Value);
string src = @"<img src=""http://www.123.com/files/1.jpg"" border=""1"" align=""left"" class=""student"" /><img src=""http://www.123.com/files/2.jpg"" border=""1"" align=""left"" class=""student"" />";
Regex re = new Regex(@"src=""(?<http>[^""]+?)/(?<f2>[^/]+?)/(?<f3>[^/]+?)""", RegexOptions.IgnoreCase);
Match mc = re.Match(src);
while( mc.Success)
{
Response.Write(mc.Groups["http"]);
Response.Write("<br/>");
Response.Write(mc.Groups["f2"]);
Response.Write("<br/>");
Response.Write(mc.Groups["f3"]);
Response.Write("<br/>*************************<br/>");
mc = mc.NextMatch();
}
Response.End();