title: javascript match only certain letters in array
body: <p>I'm using the below in a javascript Q &amp; A chatbot. To answer for example "what is AG in the periodic table? Answer is Silver.    </p>
  
  <pre><code>if ((input.search("(what is|what's)") != -1) &amp;&amp; (input.search("(periodic table)") != -1)) {
      document.result.result.value = "Hmmmm, I don't know. Try Google!";
      for (i = 0; i &lt; Periodic_Tables.length; i++) {
          Periodic_Table = Periodic_Tables[i].split('=');
          if (input.indexOf(Periodic_Table[0]) != -1) {
              document.result.result.value = Periodic_Table[1];
          }
      }
      return true;
  }
  </code></pre>
  
  <p>Then I have in another file the array laid out like this:</p>
  
  <pre><code>Periodic_Tables=new Array(
  
  "h=Hydrogen", 
  "he=Helium", 
  "li=Lithium",
  "be=Beryllium",
  "b=Boron", 
  "c=Carbon", 
  "n=Nitro­gen", 
  "o=Oxygen",
  "f=Fluorine", 
  "ne=Neon", 
  "na=Sodium",
  "mg=Magnesium", 
  "ag=Silver" 
  );
  </code></pre>
  
  <p>My problem is because the table symbols are only 1 or 2 letters it's matching a lot of wrong things. How can I set this up where "only" b matches boron, be matches beryllium. etc I've looked a word boundaries but can seem to figure out how to use them here.</p>