Last active
April 5, 2019 12:01
-
-
Save sshaw/723b9699b3c7713029311bf97a17e0c0 to your computer and use it in GitHub Desktop.
Run-length encoding in Perl. Does not support integers :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -E'print $+[1]-$l,$& and $l=$+[1] while $ARGV[0] =~ /(.)(?!\1)/g' aaabbbcdeee | |
3a3b1c1d3e | |
perl -E'print $2 x $1 while $ARGV[0] =~ /(\d+)(.)/g' 3a3b1c1d3e | |
aaabbbcdeee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment