title: JavaScript check if string contains any of the words from regex
body: <p>I'm trying to check if a string contains any of these words:</p>
  
  <pre><code>AB|AG|AS|Ltd|KB|University
  </code></pre>
  
  <p>My current code:</p>
  
  <pre><code>var acceptedwords = '/AB|AG|AS|Ltd|KB|University/g'
  var str = 'Hello AB';
  
  var matchAccepted = str.match(acceptedwords);
  console.log(matchAccepted);
  
  if (matchAccepted !== null) { // Contains the accepted word
      console.log("Contains accepted word: " + str);          
  
  } else {
      console.log("Does not contain accepted word: " + str);
  
  }
  </code></pre>
  
  <p>But for some strange reason this does not match.</p>
  
  <p>Any ideas what I'm doing wrong?</p>