title: Javascript match function
body: <p>How do I give expression inside <code>match</code> function in javascript?</p>
  
  <p>Eg.</p>
  
  <pre><code>var val = $('#somElement').val();
  var startWith = '#'
  var match = val.match('/(\s)?' + startWith + '(.*?)(\s+|$)/'g);
  </code></pre>
  
  <p>The match function takes in a parameter without string and hence the above line is wrong. How do I change it so that I can give in the parameter to val.match dynamically based on my variable's value?</p>