I have an array of words e.g. apple, banana, horse which I want to have in a later function as split points.
I found this how to concat regex expressions, but it is for a fixed number of expressions: How can I concatenate regex literals in JavaScript?
Question: How to join an array of regex expressions?
filterTemp = [];
for (i = 0, len = filterWords.length; i < len; i++) {
word = filterWords[i];
filterTemp.push(new RegExp("\b" + word + "\b"));
}
filter = new RegExp(filterTemp.source.join("|"), "gi");
return console.log("filter", filter);