I would like to split a string based on three factors.
Regex is case insensitive
If the string contains any of the terms "Red hot", "Ice cold", "Warm" or "Mild" So for example if the string is "Red hot Ice cold", when I run .split(regex) on the string, I should get an array with "Red hot" and "Ice cold" as two separate entries.
If the string does not match any of the terms, it should then split based on whitespace. So for example if the string is "Red Ice", it should split into an array containing "Red" and "Ice". It currently splits into "Red Ice" as one entry in the array. If the string is "Red hot Ice cold red", it should split into an array containing "Red hot", "Ice cold" and "red". It currently splits into "Red hot" and "Ice cold red".
So far the regex I have is "(?i)\s(?=("Red hot"|"Ice cold"|"Warm"|"Mild"))"
How do I add the criteria that if none of the terms match, it should split on white space? I don't understand how to add priority to the regex. Thanks all!