PHP: preg_match
<p>i need to write a case which only except the a-zA-Z0-9 characters with underscore and white space(1 or more than 1) and ignore all rest of the characters.I wrote a code but its not working properly.
In those case should be wrong but its show OK </p>

<pre><code>1) test msg@ 
2) test@msg  
3) test!msg
</code></pre>

<p>also those should be OK but currently shows wrong.</p>

<blockquote>
  <p>1) test  msg.-(Two white space)</p>
</blockquote>

<p>what i should to change in my code .pls help and see my code below.</p>

<pre><code>$message=$_GET['msg'];

if(preg_match('/[^A-Za-z0-9]\W/',$message))
{
   echo "Wrong";
}
else
{
 echo "OK";
}
</code></pre>
