title: Matching special characters and letters in regex
body: <p>I am trying to validate a string, that should contain letters numbers and special characters <code>&amp;-._</code> only. For that I tried with a regular expression.</p>
  
  <pre><code>var pattern = /[a-zA-Z0-9&amp;_\.-]/
  var qry = 'abc&amp;*';
  if(qry.match(pattern)) {
      alert('valid');
  }
  else{
      alert('invalid');
  }
  </code></pre>
  
  <p>While using the above code, the string <code>abc&amp;*</code> is valid. But my requirement is to show this invalid. ie Whenever a character other than a letter, a number or special characters <code>&amp;-._</code> comes, the string should evaluate as invalid. How can I do that with a regex? </p>