title: Match a list of strings using RegEx
body: <p>I have a function that highlights any amount of a single word in a string in AngularJS. I want to change this so it highlights any of the words I input in an array instead, but I'm not sure how to word the RegExp. Here is the current RegExp:</p>
  
  <pre><code>$scope.highlight = function(haystack) {
      return $sce.trustAsHtml(haystack.replace(new RegExp(needle, "gi"), function(match) {
          return '&lt;span class="highlightWord"&gt;' + match + '&lt;/span&gt;';
      }));
  };
  </code></pre>
  
  <p>The current "needle" variable is just a plain string, like 'cats', but I want to change that so it includes <code>['cats', 'registered', 'dog']</code> and so on.</p>