'ABABABA' =~ /ABA/g; # only matches twice #^^^ ^^^ here and here # ^^^ not here #### $_ = 'ABABABA'; while (/ABA/g) { print pos($_), "\n"; pos($_)--; }