求一获取图片的正则表达式
<IMG src= "U1596P1T1D12987186F21DT20070515024353.jpg " border=0> 赛时跟人过招被人打倒了但不灰心很快能反击的那种人。”吴莹莹还表示,担任这个职位,
<IMG height=180 src= "U1596P1T1D12950772F21DT20070510062211.jpg " width=240 border=0>
通过正则表达式获取上面内容里面的IMG 信息,要求获得第一个IMG信息: <IMG src= "U1596P1T1D12987186F21DT20070515024353.jpg " border=0>
------解决方案-------------------- <img [^/> ]* />
------解决方案--------------------楼上正解
------解决方案--------------------string test = @ " <IMG src= " "U1596P1T1D12987186F21DT20070515024353.jpg " " border=0> 赛时跟人过招被人打倒了但不灰心很快能反击的那种人。”吴莹莹还表示,担任这个职位,
<IMG height=180 src= " "U1596P1T1D12950772F21DT20070510062211.jpg " " width=240 border=0> ";
string resultStr = " ";
Match m = Regex.Match(test, @ " <img\s[^> ]*?src= " "(? <src> [^ " "]*?) " "[^> ]*?> ", RegexOptions.IgnoreCase);
if (m.Success)
{
resultStr = m.Groups[ "src "].Value;
}
如果要获取的是:U1596P1T1D12987186F21DT20070515024353.jpg,用上面的
如果要获取的是: <IMG src= "U1596P1T1D12987186F21DT20070515024353.jpg " border=0>
if语句内改为:resultStr = m.Value;