View Full Version : Username regular expression
I am trying to change this to only accept a-z 1-9 ` ^ - _ [ ] | and no spaces.
I found ^[A-Z0-9] which i understand does a-z and 0-9 - but how can i add in those other few characters that i want?
thanks in advance
Dismounted
06-06-2008, 08:51 AM
/^([ a-z0-9`\^-_\[\]\|]+)$/i
Thank you.
There appears to be a problem with that. I just tried to sign up as testing-all but it wouldn't accept it.
Dismounted
06-07-2008, 07:02 AM
Try:
/^[ a-z0-9`\^\-_\[\]\|]+$/i
That doesn't seem to work either. If i use just ^[A-Z0-9] that will allow letters, numbers and NO spaces right?
RLShare
06-18-2008, 10:53 PM
Shouldn't it have both A-Z and a-z to account for all uppercase and lowercase letters? I've only messed with regular expressions in Python but it seems that it should still be the same.
Eikinskjaldi
06-19-2008, 12:17 AM
Shouldn't it have both A-Z and a-z to account for all uppercase and lowercase letters? I've only messed with regular expressions in Python but it seems that it should still be the same.
the /i switch means case insensitive.
as for the regex. Quite why you would want back ticks, bars and square brackets in usernames is beyond me. is your site called www.easy.to.hack.com?
the hyphen should go unescaped at the end, I have no idea if backticks need escaping, or if they or anythig else is being weeded out by vb.
/^[ a-z0-9`\^_\[\]\|-]+$/i
or
/^[ a-z0-9\`\^_\[\]\|-]+$/i
are my guesses
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.