I created a regex with the string I am searching for by:
var re = new RegExp(searchTerm, "ig");
And i have an array that I want to search through that has these terms:
var websiteName = [
"google", "youtube", "twitter", "medium", "amazon", "airbnb", "campaiyn", "uber", "dropbox", "asana",
"slack", "soundcloud", "reddit", "uscitp", "facebook"
];
If my search term is reddit testtest test, I would not get a match when I call the match function:
for(var i = 0; i < websiteName.length; i = i + 1) {
if(websiteName[i].match(re) != null) {
possibleNameSearchResults[i] = i;
}
}
How can i structure my regex statement so that when I search through my array that it will still return true if just one of the words match?