followd by your code , only one index can be found
a poor method about do exec() like this:
var sToMatch = "a bat, a Cat, a fAt baT, a faT cat";
var reAt = /at/gi;
var a0 = reAt.exec(sToMatch);
var a1 = reAt.exec(sToMatch);
var a2 = reAt.exec(sToMatch);
var a3 = reAt.exec(sToMatch);
var a4 = reAt.exec(sToMatch);
var a5 = reAt.exec(sToMatch);
var a6 = reAt.exec(sToMatch);
alert(a0 + a1 + a2 + a3 + a4 + a5 + a6);
but the description from
JS Reference 1.5 is :
exec :
Executes the search for a match in a specified string. Returns a result array.