How to use a regex to match if any pattern appears once out of many times in a given sequence

You can use Negative lookahead if there is an option.

First match the sentence that you want to fail, in your case, it is "THE TREE IS GREEN" then give the most generic case that wants to catch your desired result.

(?!THE TREE IS GREEN)(THE[ ]+TREE[ ]+IS[ ]+GREEN)

https://regex101.com/r/EYDU6g/2


You can just search for the spaces that you're looking for:

/ {2,}/ will work to match two or more of the space character. (https://regexr.com/4h4d4)

You can capture the results by surrounding it with parenthesis - /( {2,})/

You may want to broaden it a bit.
/\s{2,}/ will match any doubling of whitespace. (\s - means any whitespace - space, tab, newline, etc.)

No need to match the whole string, just the piece that's of interest.