Created
March 23, 2012 14:06
-
-
Save Capncavedan/2170952 to your computer and use it in GitHub Desktop.
Output set of numbers as ranges
This file contains 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
# courtesy of http://codepad.org/tBON208e | |
$_ = "1,2,3,8,9,12,15,17,18,19,20,21,22,23"; | |
s/(?<!\d)(\d+)(?:,((??{$++1})))+(?!\d)/$1-$+/g; | |
print; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment