title: PHP Regular expression for only allowing alphanumeric, dashes, underscores
body: <p>I'm very new to using regular expressions and am trying to allow only <code>A-Z, a-z, 0-9, -, _</code></p>
  
  <p>I'm using the following expression which is working:</p>
  
  <pre><code>preg_match('/^[a-zA-Z0-9-_]+$/i', $_POST['sign_up_username'])
  </code></pre>
  
  <p>My question is if this is the correct way to go about doing this. I'm not sure if this is the right place to post this. Any help would be great. Thanks.</p>