title: PHP - Regex for a string of special characters
body: <p>Morning SO. I'm trying to determine whether or not a string contains a list of specific characters.</p>
  
  <p>I know i should be using <a href="http://php.net/manual/en/function.preg-match.php" rel="noreferrer">preg_match</a> for this, but my regex knowledge is woeful and i have been unable to glean any information from other posts around this site. Since most of them just want to limit strings to a-z, A-Z and 0-9. But i do want some special characters to be allowed, for example: <code>! @ £</code> and others not in the below string.</p>
  
  <p>Characters to be matched on: <code># $ % ^ &amp; * ( ) + = - [ ] \ ' ; , . / { } | \ " : &lt; &gt; ? ~</code></p>
  
  <pre><code>private function containsIllegalChars($string)
  {
      return preg_match([REGEX_STRING_HERE], $string);
  }
  </code></pre>
  
  <p>I originally wrote the matching in Javascript, which just looped through each letter in the string and then looped through every character in another string until it found a match. Looking back, i can't believe i even attempted to use such an archaic method. With the advent of json (and a rewrite of the application!), i'm switching the match to php, to return an error message via json.</p>
  
  <p>I was hoping a regex guru could assist with converting the above string to a regex string, but any feedback would be appreciated!</p>