in reply to Re^2: Convert an array of numbers into a range
in thread Convert an array of numbers into a range
For older perls without the /r
#!/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}))+/-$2/g; print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Convert an array of numbers into a range
by rmocster (Novice) on Jul 22, 2016 at 00:57 UTC | |
by Anonymous Monk on Jul 22, 2016 at 01:01 UTC | |
by rmocster (Novice) on Jul 22, 2016 at 01:04 UTC | |
by Anonymous Monk on Jul 22, 2016 at 01:07 UTC | |
by rmocster (Novice) on Jul 22, 2016 at 01:18 UTC | |
by Anonymous Monk on Jul 22, 2016 at 01:43 UTC | |
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 | |
|