my $str = "foo baa bzz"; print $str, $/; $str =~ s< ([A-Za-z]) (?:\1)+ >($1)gx; print $str, $/; __output__ foo baa bzz fo ba bz