- or download this
my $str = 'xx556xx';
my @x = grep --$|, $str =~ m/((.)\2*)/g;
print join ',', @x;
- or download this
my $str = 'xx556xx';
my $tog = 0;
my @x = grep $tog = !$tog, $str =~ m/((.)\2*)/g;
print join ',', @x;
- or download this
my $str = 'xx556xx';
my $tog = 0;
my @x = grep $tog = !$tog, split /(?<=(.))(?!\1)/, $str;
print join ',', @x;