I have a large text string and about 200 keywords that I want to filter out of the text.
There are numerous ways todo this, but I’m stuck on which way is the best:
1) Use a for loop with a gsub for each keyword
3) Use a massive regular expression
Any other ideas, what would you guys suggest
A massive regex is faster as it’s going to walk the text only once.
Also, if you don’t need the text, only the words, at the end, you can make the text a Set of downcased words and then remove the words that are in the filter array. But this only works if you don’t need the “text” to make sense at the end (usually for tags or full text search).