Was trying to refer to this (Return positions of a regex match() in Javascript?) to extract beginning and ending position of matches in a particular string but somehow it only returns 1 match. Not sure what I'm doing wrong.
var str = "abc <span djsodjs> ajsodjoasd <spandskds>";
var patt = /.*(<span.*>).*/igm;
while (match = patt.exec(str)) {
console.log(match.index + ' ' + patt.lastIndex);
}
returns
0 41
expected:
0 41
4 17
30 40