Fix hang in re matching on nearly-matches.