I have a set of words like
var words = ["champ", "winner", "world"];
var string = "I am a champ"; should match
var string2 = "I am achamp"; should match
var string3 = "I am a win ner"; should match winner [or for efficency we can prevent match too, but only last resort]
var string4 = "I am not able to figure this"; no
// I want to be able to match the words in string, string1, string2 with the words in the // list of array efficently as the word array will be huge in size.This is what i have // // conjured.
var x = string.split(' ');
var x1 = string2.split(' ');
var x2 = string3.split(' ');
var x3 = string4.split(' ');
if (words.some(v => x1.includes(v))) { // only works for string but not for others
console.log('Yes');
} else {
console.log('No');
}
How to make sure i am able to match words in my sentence efficiently and also we can have punctuation like " ? / etc , which i am thinking to remove and work with to make the check easier . how can i do it efficiently and fast in client as the list can be atleast 1k.