Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- simple pregmatch


Sandro87 - 1:27 pm on Apr 11, 2010 (gmt 0)


This is stupid I know, but I can't find a way to do it, I know the expressions but I don't know where and how to set them..

I have

if (!preg_match ("/([a-z0-9._]+)+$/", trim($_POST["username"]))){

dosomething

}

I need to verify that "username" has only upper/lowercase chars with "." and "_" allowed. but I want also to NOT allow whitespaces in the username

I tried the followings with no success

/([a-z0-9._^\s]+)+$/
/([a-z0-9._\S]+)+$/
/([a-z0-9._^ ]+)+$/

Thank you


Thread source:: http://www.webmasterworld.com/php/4113847.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com