js 正则exec()函数在循环中使用

在每次循环中,需要把正则表达式的lastIndex重置为0。如
reg.lastIndex=0