in reply to Re: Regex help
in thread Regex help

Very cool, but the output of print $2, $/ while /(\b\w+\b)(?=(.*?)\1)/g; is:

brown fox jumped over the other fox jumped over the other quick jumped over the other quick brown o #????
In order to pass over the "o" (from "the o_the_r") the backreference in the lookahead needs to be anchored to word boundaries, ie:

print $2, $/ while /(\b\w+\b)(?=(.*?)\b\1\b)/g;

Not to mention, what is the desired output if the string is "the one the two the"?