title: RegExp case insensitive search for whole word with variable
body: <p>I have an object with strings properties I want to compare to multiple user inputs using case insensitivity. My goal is to match input strings to object strings to increment the associated value by 1 (if it's a match). </p>
  
  <pre><code>var objArr = [
      {"O": 0},
      {"foo": 0},
      {"faa": 0},
      {"A": 0}
  ];
  </code></pre>
  
  <p>Everything is working smoothly except for the case insensitivity. The RegExp method I used just looks for one letter instead of the whole word. I'm probably not using the right syntax, but I can't find results on google which explain the <code>/i</code> flag along with a variable.
  My closest try was :</p>
  
  <pre><code>var re = new RegExp(b, "i"); //problem here 
  if (allinputs[i].value.match(re)) { //and here
  </code></pre>
  
  <p>This code indeed allows case insensitivity but it doesn't look for the whole object property string and stops for letters. For exemple typing "foo" will result in a match to "O" because it contains the letter "O", and the property "O" is before "foo". Accordingly, typing "faa" matches to "faa" and not "A", because "faa" is before "A" in the objects array. Strings that don't exist in my object like "asfo" will still be matched to "O" because of the one common letter.</p>
  
  <p>Is there a way to search for <strong>the whole</strong> property string with case insensivity using the <code>regExp</code> <code>/i flag</code> ? I want to avoid using .toUpperCase() or .toLowerCase() methods if possible.</p>
  
  <p>Fiddle here : <a href="https://jsfiddle.net/Lau1989/b39Luhcu/" rel="nofollow">https://jsfiddle.net/Lau1989/b39Luhcu/</a></p>
  
  <p>Thanks for your help</p>