This is only when using the g flag. I agree that this is not the best design, but you need to allow you to scroll through the matches, for example. with re1.exec .
var s = "fo1,fo2,fo3,"; var re1 = /fo\d,/g; var match; while(match = re1.exec(s)) { alert(match); }
Matthew flaschen
source share