I want to find an img tag in a string. I wrote for example:
var str ='<img border="1" height="165" id="img2" src="http://google.jpg" />';
var regXstr = "<img (.)*/>";
var regX = new RegExp(regXstr , 'gi');
document.write(str.match(regX));
and the output is the whole text in str
which is good in this case, but the if I switch the str
with the following:
var str ='<img border="1" height="165" id="img2" src="http://google.jpg" /> /> />';
or with
var str ='<img border="1" height="165" id="img2" src="http://google.jpg" /><span/>';
the result is still the whole text in str
, and I want only the img tag - from <img
till first />