Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex for Username?

I am using C# and jQuery to valid a username with Regex. Just learning :) So far I have

UserName = "[a-zA-Z0-9]";

But this doesn't stop symbols ? How to ensure that no symbols or " . " or " _ " ?

Thanks

like image 560
Murray Avatar asked May 04 '10 09:05

Murray


People also ask

How do I validate a regex?

If it doesn't have to be in code, you can go to regexr.com, and paste in your regex, and type in the text you're matching it up against. Why don't you want to check preg_match() against false? Some answers do not consider that MAYBE the regex to be validated comes from the input of an admin user of an app...


1 Answers

That regex says "At least one letter or number" you want "Every character from the start to the end is a letter or number"

"^[a-zA-Z0-9]+$"
like image 113
Quentin Avatar answered Sep 22 '22 13:09

Quentin