#!/usr/bin/perl use strict; use warnings; my @found; # 0 1 2 3 4 5 # 012345678901234567890123456789012345678901234567890 $_ = q'abczdefzabcghijklzabczaerabrtyuabcethdauthabkudiabc'; # abc abc abc abc abc # 0 8 18 31 48 m< ( (?{ push @found, pos() }) abc # the string I know which repeats ) \G .+? \1 >gx; print join ', ', @found, "\n";