in reply to Match, Capture and get position of multiple patterns in the same string

Note that all solutions presented sofar will only return non-overlapping greedy matches, not all matches as the requirement is. Say for instance, you're searching for fofo in fofofo. I count two matches, but anything using while ("fofofo" =~ /fofo/g) will only find 1. And if the pattern is (?:fo)+ there are 6 potential matches (3 from position 0, 2 from position 2, 1 from position 4).

Perhaps you are only interested in non-overlapping greedy matches, but that wasn't clear to me.

$_ = "fofofo"; /((?:fo)+)(?{ say "[$-[1], $+[1], $1]" })(*FAIL)/; __END__ [0, 6, fofofo] [0, 4, fofo] [0, 2, fo] [2, 6, fofo] [2, 4, fo] [4, 6, fo]