用正则表达式获取图片img标签的url
var reg=/<img\s+.*?src=(?:'(.+?)'|"(.+?)")\s*.*?(?:>|\/>)/igm var strXml ="sdfdfsadf <img src='xx/aa.jpg'/>sdfsdfsdf<img src='gg.jpg'/>sdfsdfsd<img size='19' src='cgg.jpg' n='20'>"; var result = []; var match; while( match=reg.exec(strXml) ){ result.push(match[0],match[1]); } alert(result);
相关推荐
陌阡 2020-07-19
AHuqihua 2020-06-13
InJavaWeTrust 2020-06-04
jianxm 2020-03-28
心丨悦 2020-02-02
wangxiaoxue 2020-01-23
jyj00 2020-01-11
SDUTACM 2020-01-10
eroshn 2020-01-05
luofuIT成长记录 2019-12-30
心丨悦 2019-12-23
Darklovy 2019-12-06
YYDU 2019-11-17
cooldatabase 2019-11-17
YoungerChen 2019-11-08