in reply to Regular Expression Search

With the use of Number::Rangify and some maps and a grep:
use Modern::Perl; use Number::Rangify qw/rangify/; while (<DATA>) { my $seq; my @ranges = map { sprintf "%s-%s", $_->Size } rangify( grep $_, map { $seq++; $_ eq '-' ? $seq : '' } split // + ); say "@ranges"; } __DATA__ A---B A--B---C ABC--DE A-B--C----DEF------H
Output:
2-4
2-3 5-7
4-5
2-2 4-5 7-10 14-19

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James