in reply to Matching double characters and insertion
You can also do:
$str =~ s{((.)\2*)}{join'x',split(//,$1)}eg;
Aziz,,,