title: Validate a string to be URL safe using regex
body: <p>I have a site where users can pick a username. Currently, they can put in almost any characters including things such as @ ! # etc.</p>
  
  <p>I know I can use a regex, and that's probably what I'm opting for. </p>
  
  <p>I'll be using a negated set, which I'm assuming is the right tool here as so:</p>
  
  <pre><code>[^@!#]
  </code></pre>
  
  <p>So, how can I know all of the illegal characters to put in that set? I can start manually putting in the ones that are obvious such as !@#$%^&amp;*(), but is there an easy way to do this without manually putting every single one of them in?</p>
  
  <p>I know a lot of sites only allow strings that contain alphabets, numbers, dashes, or underscores. Something like that would work well for me.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks S.O.!</p>