I have a sentence (words delimited by spaces).
I then have two lists of phrases (full or partial words i.e. contain no spaces): one is an 'include' list and the other is an 'exclude' list.
A matching sentence will contain all phrases in the 'include' list (overlaps are OK, case insensitive) and none of the phrases in the 'exclude' list.
How to test whether the sentence meets the rules? Thanks.
Example
Sentence = This yammy Flybe catalog is sticky
Include list = cat
fly
tic
Exclude list = veg
pot
yam
Test fails because, although all the 'include' phrases are in the sentence, one of the 'exclude' phrases (yam
) does appear. Change the word yammy
to yummy
and the test should pass.
P.S. currently using relation division implementation in SQL for this, which seems well optimized when the data is aleady in the SQL database. Now I have a data structure coming from an external source. I suppose I could pass in the delimited strings, split into table rows, etc but I want to investigate other options. So if not regex then what?