title: Python Regex Match Special Characters
body: <p>I need a function that can test whether a string has any special characters in it. I'm currently using the following function with no luck:</p>
  
  <pre><code>import re
  
  def no_special_characters(s, pat=re.compile('[@_!#$%^&amp;*()&lt;&gt;?/\|}{~:]')):
    if pat.match(s):
      print(s + " has special characters")
    else:
      print(s + " has NO special characters")
  </code></pre>
  
  <p>I get the following results:</p>
  
  <pre><code>no_special_characters('$@')  # $@ has special characters
  no_special_characters('a$@') # a$@ has NO special characters
  no_special_characters('$@a') # $@a has special characters
  </code></pre>
  
  <p>This doesn't make any sense to me. How can I test for ANY special characters in a string?</p>