in reply to regex backreference

sorry to trouble you once more, i have changed my regex into:

$tekst=~/(\b\w{3}\b)(?=.*\b\1\b)/g

And it appears to be working. Can someone explain the look ahead assertion.The part:

 ?=.*\b\1\b

It seems to me this ought to be ?=\1.

I dont understand it like this. Thank you.

Replies are listed 'Best First'.
Re^2: regex backreference
by Corion (Patriarch) on Dec 01, 2013 at 13:42 UTC

    Maybe trying it against some data helps you understand why word boundaries are necessary.

    foo foo kungfoo foo foobar foo fool