http://qs1969.pair.com?node_id=488587


in reply to Problem in "index" function in recognizing repeating substrings

index accepts a position to start from as a third argument. If you track $id to figure out where in the string you are, you should be able to avoid matching the first instance repeatedly.

See the docs for more information.