in reply to Re^4: Convert an array of numbers into a range
in thread Convert an array of numbers into a range
#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1168288 use strict; use warnings; my @ra = qw(0001 0002 0003 011 012 013 015 16 17 18 20); $_ = join ',', @ra; s/\b(\d+)(?{$1})\K(?:,(\d+)\b(??{++$^R!=$2||length$1!=length$2}))+/-$2 +/g; print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Convert an array of numbers into a range
by rmocster (Novice) on Jul 22, 2016 at 01:18 UTC | |
by Anonymous Monk on Jul 22, 2016 at 01:43 UTC | |
|
Re^6: Convert an array of numbers into a range
by rmocster (Novice) on Aug 27, 2016 at 07:29 UTC | |
by Anonymous Monk on Aug 27, 2016 at 09:39 UTC | |
by rmocster (Novice) on Sep 29, 2016 at 22:39 UTC | |
by AnomalousMonk (Archbishop) on Sep 29, 2016 at 23:54 UTC | |
by rmocster (Novice) on Oct 04, 2016 at 23:18 UTC |