title: Match all phrases and push element to array
body: <p>I am trying to match all typed phrases(characters) with main array. I have a big array, when user types something i want to search my array and show only matching entries, for example: if user types puzzle then from my array 'my puzzle starts','enter your puzzle' these both should match.</p>
  
  <p>I have created <strong><a href="http://jsfiddle.net/3wnsfyf2/" rel="nofollow noreferrer">Fiddle</a></strong> here, here is my html code</p>
  
  <pre><code>Search: &lt;input autocomplete="off" type="text" id="search" /&gt;&lt;br /&gt;
  Results: &lt;input type="text" id="results_count" /&gt;&lt;br /&gt;
  &lt;textarea id="results_text" style="width:300px; height:500px"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>My js code</p>
  
  <pre><code>var string =['1234sud','man in puzzle','rocking roll','1232 -powernap','all_broswers'];
  $('#search').keyup(function() {
    var search = $(this).val();
    var resultsText = $('#results_text');
    var resultsCount = $('#results_count');
    if (!search) {
      resultsText.val('');
      resultsCount.val('0');
      return;
    }
    var j = 0, results = [],result;
    for   (var i=0;i&lt;string.length;i++){
    var rx = new RegExp('"([*'+search+'*])"','gi');
  
    if (rx.exec(string[i])) {
      results.push(string[i]);
      j += 1;
      if (j &gt;=100)
        break;
    }
    }
  
    //results=string;
    resultsText.val(results);
    console.log(results)
    resultsCount.val(j);
  });
  </code></pre>
  
  <p>I am not able to write that regular expression which matches types phrases (characters) with array and pushes matching element to result array. Any help will be appreciated thanks in advance. </p>