Stop string match/replace when the regexp matches empty string twice in a row as per 15.10.2.5 note 4.