Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: positions of all occurrences of a substring in a stringby Eily (Monsignor) |
on Jun 20, 2014 at 13:36 UTC ( [id://1090633]=note: print w/replies, xml ) | Need Help?? |
Using substring and iterating over the string seems simple enough, and it would work alright. If you want to use a regex, you should use look ahead assertions if you want to find occurrences that can overlap (and for pos to give you the start of the match). :
If you don't want to find overlapping occurrences, you can use @- to find the start of the last match.
In Section
Seekers of Perl Wisdom
|
|