in reply to Re: Regex help
in thread Regex help
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:brown fox jumped over the other fox jumped over the other quick jumped over the other quick brown o #????
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"?
|
|---|