there is a string like
<img src="images/_attachments/07-08.jpg" style="width: 520px; height: 693px;" /><img src="images/_attachments/09-11.jpg" style="width: 520px; height: 693px;" />
I wanna get the image path 'images/_attachments/07-08.jpg'
, 'images/_attachments/09-11.jpg'
and file name '07-08.jpg'
, '09-11.jpg'
in javascript with regular expression.
So I code like
var str='<img src="images/_attachments/07-08.jpg" style="width: 520px; height: 693px;" /><img src="images/_attachments/09-11.jpg" style="width: 520px; height: 693px;" />'
var strPattern=new RegExp('<img.*?src="(.*\/(.*?))".*?>', 'g');
var arrMatch=new Array();
var strHTML='';
while(arrMatches=_strPattern.exec(str)){
strHTML+='<div>'+arrMatches[2]+'</div>';
}
$('body').html(strHTML);
but all i get is path, not file name, how can i fix this?