Split a character string based on change of character: Difference between revisions
Split a character string based on change of character (view source)
Revision as of 16:31, 31 December 2016
, 7 years ago→{{header|Perl 6}}: Add perl 6 example
m (→{{header|JavaScript}}: repositioned {{Trans}} tag) |
Thundergnat (talk | contribs) (→{{header|Perl 6}}: Add perl 6 example) |
||
Line 212:
{{Out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
=={{header|Perl 6}}==
{{works with|Rakudo|2016.12}}
Accept a string at the command line to split, if none provided, use default.
<lang perl6>my $string = @*ARGS[0] // < gHHH5YY++///\ >;
put join ', ', $string ~~ m:g/(.)$0*/;</lang>
{{out|Default output}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
|