^start of line
Negative Lookahead(?!.*?\b(\w+)\b(?:.*\b\1\b){2}) .*?any Unicode character (except for line terminators), repeated any number of times
\ba Unicode word boundary
\w+a Unicode word character, repeated at least once
\ba Unicode word boundary
Non-Capturing Group(?:.*\b\1\b){2} {2}repeats the group contents below exactly 2 times:
.*any Unicode character (except for line terminators), repeated any number of times
\ba Unicode word boundary
\1the text saved by group 1
\ba Unicode word boundary
.*?any Unicode character (except for line terminators), repeated any number of times
\ba Unicode word boundary
\w+a Unicode word character, repeated at least once
\ba Unicode word boundary
.*any Unicode character (except for line terminators), repeated any number of times
\ba Unicode word boundary
\2the text saved by group 2
\ba Unicode word boundary
g modifier: global. Finds all matches instead of stopping after the first
m modifier: multiline. Causes ^ and $ to match the start and end of each line, not only the start and end of the string