Regex to test if an input string contains a certain number of characters
Posted
by Dan
on Stack Overflow
See other posts from Stack Overflow
or by Dan
Published on 2010-04-07T18:41:36Z
Indexed on
2010/04/07
18:53 UTC
Read the original article
Hit count: 216
So, I basically would like to test to see if a string contains a range of alphanumeric characters. It's to be used as a client-side validation and I don't want to prevent users from entering whatever they want. Best to give examples of what should/should not pass validation:
So to be specific, the expression I'm looking for is to test to make sure string contains anywhere from 3 to 10 alphanumeric characters. I'd like to plug into an ASP.NET client side validator.
NOTE: quotes not part of input (but could be!)
- " f o o " should pass since there are 3 chars
- "f_0_0" should pass
- " fo " should not
- "F......o......o......b.....a......r" should pass
thx
© Stack Overflow or respective owner