perl -E 'for("bababa") { say pos while /(?=baba)/g }' 0 2 #### perl -E 'for("bababa") { say $-[0] while /baba/g }' 0