I was working on a RegExp and found out that if the string contains dash aa-bb.js
and the query string part m=123
, it will cause the browser to crash, apart from not being the best Regular Expression for this purpose, I'd like to know why does it work for https://example.org/aa.js
and not for https://example.org/js/aa-bb.js?m=123
var re = /src=[\'|\"]([ -0-9a-zA-Z:]*[ 0-9a-zA-Z;]*)*[\'|\"]/g;
var result = re.exec("<script src='https://example.org/js/aa-bb.js?m=123'></script>");
console.log(result)