Split a character string based on change of character: Difference between revisions

add perl example
(Added XLISP)
(add perl example)
Line 761:
{{out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
 
=={{header|Perl}}==
{{works with|Perl|5.x}}
<lang perl>my $str = 'gHHH5YY++///\\';
$str =~ s/((.)\g{-1}*)/$1, /g; # remove trailing ,
$str =~ /s, $//;
print "$str\n";
</lang>
{{out}}
<pre>
g, HHH, 5, YY, ++, ///, \
</pre>
 
=={{header|Perl 6}}==
Anonymous user