PDA

View Full Version : Username Regular Expression


induslady
10-09-2013, 04:04 PM
Hello,
In my board, have the below setting -

User Registration Options > Username Regular Expression - ^[A-Z0-9]+$

so that it allows alpha numeric characters in user names.

But am looking for expression that does not allow user names that has ONLY numbers like - "12345".

How do I set this?

Thanks in advance.

kh99
10-09-2013, 04:47 PM
I found this: ^\d*[a-zA-Z][a-zA-Z0-9]*$

here: http://stackoverflow.com/questions/1051989/regex-for-alphanumeric-but-at-least-one-character. It allows lower case, but you could take out the lower case ranges if you want (or I guess it doesn't matter to vbulletin).

induslady
10-10-2013, 03:24 AM
Hello Kh99,
Thanks for the response. Yes it seems to be working good but I would also want to disallow user names that starts with numbers like - "1234test". In such a scenario how do you think the regex need to be?

Do you think this will work -
^[a-zA-Z][a-zA-Z0-9]+$

kh99
10-10-2013, 09:50 AM
Yes, I believe you'd just want to remove the \d* from the beginning. You could change the last * to + as you've done, but I think that would just require the username to be at least 2 characters, and vbulletin already requires at least 3.

induslady
10-11-2013, 03:00 AM
Thanks Kh99,
It did work good.