title: How to filter strings having some sequence of characters in javascript?
body: <p>Consider that I have a list of user names and I need to search for a user with a <strong>search key</strong>. For every username, if it matches the key I will add it to the search results, as indicated by the following <strong>javascript</strong> code:    </p>
  
  <pre><code>var username_1 = "amal";
  var username_2 = "sayed ali mohamed";
  var search_key = "am"; 
  var index = username_1.search(search_key);
  if(index != -1){
       console.log('Username 1 matched')
  }
  
  index = username_2.search(search_key);
  if(index != -1){
       console.log('Username 2 matched')
  }
  </code></pre>
  
  <p>As obvious, only <code>username1</code> matches the query, but it's noted that both names have the letters 'a' and 'm'. So, if I wanted both names to match, I need to use the following regular expression: <strong>.*a.*m.*</strong></p>
  
  <p><strong>Problem:</strong> given a string of characters 'c<sub>1</sub>c<sub>2</sub>c<sub>3</sub>...c<sub>n</sub>', how to convert it to the following string of characters '.*c<sub>1</sub>.*c<sub>2</sub>.*c<sub>3</sub>  ...  .*c<sub>n</sub>.*' in an efficient way with javascript ?</p>