http://qs321.pair.com?node_id=998200

Sewi has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,
a really simple RegEx problem is driving me crazy trying to find the most-often recurring char combination:
perl -le 'print $x = "abcdefgxxabcdefgzzabcdsjfhkdfab"; print $2 if $x + =~ /((\w+).*?\2.*?)+/;' abcdefgxxabcdefgzzabcdsjfhkdfab ab
Simple, but I need to match only strings with a minimum of 2 chars:
perl -le 'print $x = "abcdefgxxabcdefgzzabcdsjfhkdfab"; print $2 if $x + =~ /((\w{2,}).*?\2.*?)+/;' abcdefgxxabcdefgzzabcdsjfhkdfab abcdefg
Shows abcdefg but ab would be right (there is another abc behind the zz and another ab at the end).
perl -le 'print $x = "abcdefgxxabcdefgzzabcdsjfhkdfab"; print $2 if $x + =~ /((\w{2,}?).*?\2.*?)+/;' abcdefgxxabcdefgzzabcdsjfhkdfab cd
doesn't work either, as ab would be right.
Why doesn't {2,} match ab?
Thanks, Sewi