C:\>perl -le"print $1 while q!011122xx3x344444! =~ /((.)\2*)/g" 0 111 22 xx 3 x 3 44444