.net - regex for alphanumeric, but at least one character -


In my asp.net page, I have an input box that should have the following verification:

Must be alphanumeric, with at least 1 character (i.e. all numbers can not be).

  ^ \ d * [a-zA-Z] [a-zA-Z0- 9] * $  

In fact it means:

  • Zero or more ASCII points;
  • An alphabetical ASCII character;
  • Zero or more alphanumeric ASCII characters.

Try some tests and you'll see that it will pass an alphanumeric ASCII string where at least one non-numerical ASCII character will be required.

The key is on the \ d * front without it the regex becomes more odd to do it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -