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