title: Allow only certain character in string. Javascript
body: <p>I have no idea, why this simple code is not working. I am planning to match a string against the allowed pattern.
  The string should ONLY have <code>a-z</code>, <code>A-Z</code>, <code>0-9</code>, <code>_</code> (underscore), <code>.</code> (dot) , <code>-</code> (hiphen).</p>
  
  <p>Below is code:</p>
  
  <pre><code>var profileIDPattern = /[a-zA-Z0-9_.-]./;
  var str = 'Heman%t';
  console.log('hemant',profileIDPattern.test(str));
  </code></pre>
  
  <p>The code logs 'true' for below string, although these string DOES NOT match the pattern.</p>
  
  <pre><code>'Heman%t' -&gt; true
  '#Hemant$' -&gt; true
  </code></pre>
  
  <p>I dont know what is the problem.</p>