How would you validate a screen name using regex (on Ruby on Rails)?
I’m looking for a bit of regex to validate (in an RoR model) that a screen name does not have any symbols or spaces in it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It sounds like you want to specify a blacklist of characters that aren’t allowed, but there are a lot of characters out there that you probably don’t want in screen names so it would be better to use a whitelist. Here’s an example that would only allow letters, numbers, and underscores in screen names and restrict the length to be 2-30: