Say I have a sentence or two in a string, and I have an array of words. I need to find anywhere in the string where two or more words from the array are next to each other.
Example:
Words: ['cat','dog','and','the']
String: There is a dog and cat over there. The cat likes the dog.
Result: ['dog and cat','the dog','the cat']
The only way I've been able to do this is manually specifying possible combinations, but only for 3 words max as it gets long fast.