in reply to Finding a repeating substring with a regex

Update: fixed @$^R to @{$^R}. You can use the return value of (?{ ... }) (which is $^R) which is subject to backtracking.
$string =~ m{ (?{ [ pos ] }) # we start $^R as [ pos ] ([a-z]{3}) # find a string, store it in \1 (?: # now do this one or more times: .*? # match zero or more characters (non-greed +ily) (?{ [ @{$^R}, pos ] }) # append pos() to $^R's arrayref \1 # matching \1 at this location )+ (?{ @loc = @{$^R} }) # then save $^R }x

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart