in reply to Efficient run determination.
OK, I'm not really answering your question (I'm not using a regexp), and this is a method you have probably tried before, but if it's speed you want, how about simply converting the string to an array and looping once over its elements?
Interesting problem, BrowserUk!use strict; my $string=" aaaa bbbbccccccccbbbb aaaabbbbbcddddddddddddddddd +dddd"; my @listedstring= split//,$string; my $prev=shift @listedstring; my $currstart=my $index=0; for (@listedstring) { if ($_ eq $prev) { $index++; } else { print "('$prev',$currstart,".($index-$currstart+1).")\n"; $currstart=++$index; $prev=$_; } } print "('$prev',$currstart,".($index-$currstart+1).")\n";
CU
Robartes-
|
---|
In Section
Seekers of Perl Wisdom