I need a regex that would match the following example strings:
Example 1: "red, blue, and hot"
Example 2: "red, blue, or hot"
Three individual words, the first two followed by commas, and the conjunction 'and' (case 1) alternatively 'or' (case 2).
Case 1: "<word01>, <word02>, and <word03>"
Case 2: "<word01>, <word02>, or <word03>"
I have the following regex (\w+,(\s|\n)+){2}(and|or)
that successfully matches the strings however it will also match strings where my example expressions are contained within the string. I only want a successful match if the string contains my example expression and nothing else.
In other words green, red, blue, and hot
should not match as it contains an additional word and comma before the match.