Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am making a username field in windows form.
i have find many regex but result is not good.
I have find this regex ^[a-z0-9_-]{3,16}$
which is taking value between 3 character to 16 characters. But it is not taking uppercase letter.
I am not a regex guru. Niether i added that code in my given regex.
Can anyone help me out

thanks in advance
Posted
Updated 29-Sep-12 18:23pm
v2

1 solution

How about:
[a-zA-Z0-9_-]

Take a look at this too:
Expresso - A Tool for Building and Testing Regular Expressions[^]
 
Share this answer
 
Comments
sariqkhan 30-Sep-12 0:27am    
thanks bro. For helping
: )
sariqkhan 30-Sep-12 0:33am    
is there any thing to check whether - or underscore are at the end of the line? I want to avoid that username which have underscore or dash at end.
Kenneth Haugland 30-Sep-12 0:44am    
^[a-zA-Z0-9_-]{3,16}[^_]$
sariqkhan 30-Sep-12 0:52am    
this will matches the patters that there is underscore at end?
Kenneth Haugland 30-Sep-12 0:57am    
It will match if ther is NO underscore at the end the ^ inside the [] means not...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900