I do not understand why the javascript RegExp.test()
method do no return the same result every time I call it.
Given the following javascript variables
var opener = '<span[^>]*>';
var regexo = new RegExp('^'+opener+'$', "g");
I do the following:
alert(regexo.test('<span class="outer">')); // true
alert(regexo.test('<span class="inner">')); // false
alert(regexo.test('<span class="inner">')); // true
I tested it in Firefox 24.0 and IE8 with the same strange result.
Why is the result true, false, true
instead of true, true, true
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…