fix reg lastIndex