regex - ASP.Net Regular Expression Validator no spaces -


i'm trying set validation expression asp.net regular expression validator control. validating creation of user name, want limit number of characters, , want prevent them using spaces. here's i've got far:

^.*(?=.{5,20})(?=.*\w{5,255}).*$ 

the \w{5,255} part prevents spaces , special characters (except underscores, apparently). have no idea how "5,255" makes work, does; copied somewhere else.

the main problem i'm having if first or last character space (or special character), passes validation, not acceptable. can me? i'm sure simple, know next nothing regular expressions.

you can use simpler this:

^[a-za-z0-9_]{5,255}$

this allow alphanumeric usernames between 5-255 characters in length.


Comments

Popular posts from this blog

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

javascript - Iterate over array and calculate average values of array-parts -

jQuery Ajax Render Fragments OR Whole Page -