Fixed a bug in reg_match_all that could cause infinite loops.