Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by Not_a_Number (Prior)
on Sep 18, 2003 at 18:41 UTC ( #292485=note: print w/replies, xml ) Need Help??


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

Not particularly elegant, I suppose, but Another Way To Do It (using substr):

my $str = 'braaaafdhjklghaa'; my $sstr = 'aa'; my $len = length $sstr; for ( 0 .. ( length $str ) - $len ) { print "Found at $_\n" if substr ($str, $_, $len) eq $sstr; }

dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2020-01-23 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?