title: Checking String for illegal characters using regular expression
body: <p>I want to check a for any illegal character using the following regular expression in PHP.  Essentially, I want to allow only alphanumeric and underscore (_).  Unfortunately the follow piece of code does not seem to work properly.  It should return true if there is any illegal character in the string $username.  However, it still allows any character in the string.  Any idea what is wrong with the regular expression?</p>
  
  <pre><code>if ( !preg_match("/^[-a-z0-9_]/i", $username) )
  {
      return true;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>