Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: 'grouping' substrings?

by Cristoforo (Curate)
on Feb 02, 2006 at 02:13 UTC ( [id://527212]=note: print w/replies, xml ) Need Help??


in reply to 'grouping' substrings?

Having the luxury of time to consider it ;-) , here was my approach using index.
my @pos; my $start = index($str, 'M'); while ($start != -1) { my $pos; my $i = 0; 1 while ($pos = index($str, 'M', $start + $i)) == $start + $i++; push @pos, [$start, $start + $i-2]; $start = $pos; }
Update - fix three lines

my $i = 1; $i++ while ($pos = index($str, 'M', $start + $i)) == $start + $i; push @pos, [$start, $start + $i-1];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-03-28 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found