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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -