Find all possible starting positions of a regular expression match in perl, including overlapping matches?
Posted
by
jonderry
on Stack Overflow
See other posts from Stack Overflow
or by jonderry
Published on 2011-01-13T22:11:36Z
Indexed on
2011/01/14
22:53 UTC
Read the original article
Hit count: 181
perl
Is there a way to find all possible start positions for a regex match in perl?
For example, if your regex was "aa" and the text was "aaaa", it would return 0, 1, and 2, instead of, say 0 and 2.
Obviously, you could just do something like return the first match, and then delete all characters up to and including that starting character, and perform another search, but I'm hoping for something more efficient.
© Stack Overflow or respective owner