Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Donald DUCK : YOU ARE FIRED!!!
  • Leaders
Posted

I put it after the 9 and it seems to work

^[A-Za-z0-9\s]{6,20}$

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

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

Donald DUCK : YOU ARE FIRED!!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...