my @words = $txt =~ m/\b(\w{3})\b(?=.*\b\1\b)(?!.*\b\1\b.*\b\1\b)/g;
The (?!...) is a negative look-ahead assertion. If you leave that out, duplicates appear for words occurring more that twice. And (?=...) is the positive look-ahead assertion.
In reply to Re: regex backreference
by oiskuu
in thread regex backreference
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |