Given a collection of word combinations, is it possible to return a collection of matched word sets and extract those from a given string using RegEx?
For example, given a car list:
mazda 3
mazda 4
volvo s40
The following text is used:
“I wanted to buy a mazda 3 however I found the volvo s40 to be a much better deal with the 90gv tires.”
I how want two different lists from this that should return:
{mazda 3, volvo s40, 90gv}
{I, wanted, to, buy, a, however, I, found, the, to, be, a, much, better, deal, with, the, tires}
This code uses a MatchEvaluator for the matches (the car models), and returns “”, so the model gets replaced with empty string.
carsis a list of car models.wordsis a list of the remaining words. I’ll leave it to you to handle punctuation appropriately for your needs.Produces this output: