Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by jsegal (Friar)
on Sep 18, 2003 at 17:45 UTC ( #292470=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    while ($s =~ /abc/g) {
       print "found abc at $-[0]\n";
    }
    
  2. or download this
    while ($s =~ /aa/g) {
       print "found aa at $-[0]\n";
    }
    
  3. or download this
      found aa at 1
      found aa at 3
    
  4. or download this
    while ($s =~ /aa/g) {
       print "found aa at $-[0]\n";
       pos($s) = $-[0] + 1;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://292470]
Approved by ybiC
Front-paged by sgifford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2020-01-22 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?