cooldude832 Posted July 22, 2007 Share Posted July 22, 2007 I'm trying to do a regex that will check to make sure a user name is >5 characters and only contains numbers/alphas/underscode. Any ideas? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 22, 2007 Share Posted July 22, 2007 A simple bit of regex: <?php $username = 'c00l_Dude'; // valid //$username = 'cooldude832'; // valid //$username = 'c00l'; // Invalid //$username = 'Cool-Dude'; // Invalid if(preg_match('/^([A-Z0-9_]){5,}$/i', $username)) { echo $username . ' - Valid'; } else { echo $username . ' - Invalid'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.