title: Returning an exact match from a JavaScript array using RegExp
body: <p>I have an array of people and want to filter on some criteria, in this case I want to search for a "male" which should return just one result however with this set I'm getting everything back because the regular expression is capturing female as well.</p>
  
  <p>I tried matching on "\bmale" or "/\bmale" but didn't get anything back. I know I need to use a word boundary but for some reason it's not working out.</p>
  
  <pre><code>var people = [["Adelaide", 2, "yes", "female"],
             ["Ada", 2, "yes", "female"],
             ["Amanda", 1, "yes", "female"],
             ["Wolf", 3, "no", "male"],
             ["Rhonda", 1, "no", "female"]];
  
  var isMale = function(x) {
    var myMatch = new RegExp("male");
    var test = String(x).match(myMatch);
    return String(x).match(myMatch);
  }
  
  
  var filteredArray=people.filter(isMale);
  
  document.writeln(filteredArray); 
  </code></pre>