title: Check string for high ascii, punctuation, other weird characters
body: <p>I've got a string called <code>$ID</code> coming in from a different page and hitting <code>base64_decode($enc);</code> and want to check it for any weird characters. <code>$ID</code> when decrypted should only contain letters, numbers, underscores and dashes.</p>
  
  <p>I've had a bit of a look at <code>preg_replace('/[\x80-\xFF]/', '', $string);</code> which cuts out some weird characters---which is helpful---but I can still see sometimes that @ signs and brackets and stuff still make it in.</p>
  
  <p>Is there a way I can lower the ascii test? Or how else do I cut out everything except letters, numbers, underscores and dashes?</p>
  
  <p>Any help at pointing me in the right direction is wonderful and thanks!</p>
  
  <pre><code>$enc = $_GET["key"];
  $ID= base64_decode($enc);
  
  if (empty($enc)) { echo "key is empty"; } else {
  
      echo "string ok&lt;br&gt;"; 
  
      $check = preg_replace('/[\x80-\xFF]/', '', $ID);
      echo $check;
      // i can see this step is helping cut junk out, do more tests from here
   }
  </code></pre>