前台js读出页面的所有html源码存储在 string 里我想获取图片的名称:
...<IMG id=IMG1 style="DISPLAY: inline" alt=iBanner onerror="javascript:this.src=''" src="http://localhost:2673/Platform/Image/AllBanner/join.jpg" width="100%">...
我想取出 join.jpg 有没有什么好方法?
...<IMG id=IMG1 style="DISPLAY: inline" alt=iBanner onerror="javascript:this.src=''" src="http://localhost:2673/Platform/Image/AllBanner/join.jpg" width="100%">...
我想取出 join.jpg 有没有什么好方法?
string source = "http://localhost:2673/Platform/Image/AllBanner/join.jpg";
Regex reg = new Regex(@"/([^/.]+.jpg)");
Match mm = reg.Match(source);
MessageBox.Show(mm.Groups[1].Value);
if(reg.test(yourhtml))
var result=RegEx.$1;
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection m = r.Matches("");
foreach(Match m in mc)
{
Console.WriteLine(mc.Groups["src"].Value);
}
<IMG *** alt=iBanner *** src="http://***/Platform/Image/AllBanner/***" width="100%">***内容不确定,什么都可能是其他的确定,求正则
<IMG id=IMG1 style="DISPLAY: inline" alt=iBanner onerror="javascript:this.src=''" src="http://localhost:2673/Platform/Image/AllBanner/join.jpg" width="100%">
部分东西,在进行1楼的操作
if(reg.test(yourhtml))
alert(RegExp.$1);C#:
Regex reg=new Regex(@"(?i)<img\b[^>]*alt=iBanner[^>]*\/(.+\.\(?:jpe?g|bmp|gif))"[^>]*>");
string img= Regex.Match(str, pattern).Value;
http://www.cnblogs.com/insus/archive/2012/10/30/2745843.html