preg_match how should I use
<p>I have a string to check and if it is only numbers and digits perform another action else exit;</p>

<pre><code>$data = 123412347JB91742F;

 if(preg_match('/[A-Z1-9]/', $data )) {
  echo $data;

} 
else { 
  exit; 
}
</code></pre>

<p>this works fine but if I add anything to <code>$data</code> like <code>$</code> or any other thing it still prints the value. What is wrong with this code?</p>

<h2>Edit:</h2>

<pre><code>$data = preg_replace('/\-/', '', '1234-1234-JB91-8742F');

if(preg_match('/^[A-Z1-9]+$/', $data )) {
    echo $data;
} else {
    exit;
}
</code></pre>
