I looked at several examples on how to use regex in JS but I can not seem to find the right syntax for what I need. Basically I have an array of words:
commonWords=["she", "he", "him", "liked", "i", "a", "an", "are"]
and a string:
'She met him where he liked to eat "the best" cheese pizza.'
Basically I want to use non-alphas and my array of commonWords as delimiters for extracting phrases. The above would yield somthing like this:
'met, where, to eat, the best, cheese pizza'
From the OP:
This does both (unlike some other answers 😉 ). It returns either a string or an array.
.
This returns: