update regex test count + get regex.exec index outside of the loop