how to prevent white spaces in a regular expression regex validation

Posted by Rees on Stack Overflow See other posts from Stack Overflow or by Rees
Published on 2010-05-16T06:57:30Z Indexed on 2010/05/16 7:00 UTC
Read the original article Hit count: 334

Filed under:
|
|

i am completely new to regular expressions and am trying to create a regular expression in flex for a validation.

using a regular expression, i am going to validate that the user input does NOT contain any white-space and consists of only characters and digits... starting with digit.

so far i have:

expression="[A-Za-z][A-Za-z0-9]*"

this correctly checks for user input to start with a character followed by a possible digit, but this does not check if there is white space...(in my tests if user input has a space this input will pass through validation - this is not desired) can someone tell me how i can modify this expression to ensure that user input with whitespace is flagged as invalid?

© Stack Overflow or respective owner

Related posts about regex

Related posts about flex