How to check if a string contains text from an array of substrings in JavaScript?

Pretty straight forward. In javascript, I need to check if a string contains any substrings held in an array. Answer There’s nothing built-in that will do that for you, you’ll have to write a function for it. If you know the strings don’t contain any of the characters that are special in regular expressions, then you can cheat a bit, like this: …which creates a regular expression that’s a series of alternations for the substrings you’re looking for (e.g., one|two) and tests to see if there are matches for any of them, but if any of the substrings contains any