I have a simple check to see if someone is using any non-allowed characters in their usernames:
if(!preg_match("!^[a-z0-9_~]{1,30}$!i", $uname))
{
echo "You have entered an invalid username.";
}
But in addition to that, I would like to be able to print out which specific characters were bad. Any suggestions on how to do that?