Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Elegant (i.e. declarative) way to find all possibly overlapping matches

by Zaxo (Archbishop)
on Sep 18, 2003 at 18:17 UTC ( #292478=note: print w/replies, xml ) Need Help??


in reply to Elegant (i.e. declarative) way to find all possibly overlapping matches

As long as you're looking for literal strings instead of regex matches,

my $spot = 0; while (($spot = index $s, 'aa', $spot) != -1) { printf "found aa at %d\n", $spot++; }
The increment in the loop is important.

After Compline,
Zaxo

  • Comment on Re: Elegant (i.e. declarative) way to find all possibly overlapping matches
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2020-01-23 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?