Use RegExp to restrict spaces

microkarl

Regular
Joined
Apr 22, 2004
Messages
88
Location
Morristown, NJ
Hi all,

I want to enhance this regular expression - ^[0-9a-zA-Z]{6,20}$ to not allow any spaces (leading, in between, and trailing). I know the regexp for space is (\s*), but just don't know how to put them together. Can any one help?

Regards,
Kyle
 
Iceplug, thanks for your respond. It doesn't work. It works like this:
- "Test1" - no match (expected)
- "Test1 " - no match (expected)
- "Test123" - match (expected)
- "Test123 " - match (not expected)

Basically, if I have string is less than 6 characters, regardless the spaces, it should fail. But as long as the string is with 6-20 chars. the regex allows spaces. which is not allowed. Can you help?

Thanks.
carl
 
Back
Top