Reputation: 7664
could someone help my build a regex? It is for a username check
the requirements are
Thanks, Vidhu!
Upvotes: 0
Views: 47
Reputation: 440
\w gives you any "word" character (number, letter, underscore of any case) and - is just a dash.
[\w-]*
http://www.rubular.com is a great site to test regular expressions. It has a good reference too.
Upvotes: 3
Reputation: 9920
I think the following accomplishes all three:
[A-Za-z0-9\-_]*
Or better still:
[\w\-]*
Upvotes: 2