New forum member has username with emoji

wcbryant

Active member
Not having migrated yet, I have to ask... Is there an ACP option to limit usernames to alphanumeric characters?
 

Jeremy

Well-known member
No. That will reject a decent amount of usernames. You'll want to use:
^[a-zA-Z0-9 ]+$

Your RegEx disallows lower case. ;)

But yes, such RegEx will prevent Emoji. It also removes the possibility of punctuation.
 

Jeremy

Well-known member
Glad I checked, that's different from vB. Thanks again.
If you are using that RegEx in vBulletin you should only be getting capital letters, numbers, and spaces.

The difference between yours and mine is I allow lower case.
 

wcbryant

Active member
I'm using mine in vB and there are no issues with lowercase registrations, but I appreciate the difference between yours and mine as it speaks to what I need (yours) on XF. Apologies for the soft hijack here, cmeinck.
 

Jeremy

Well-known member
No. That will reject a decent amount of usernames. You'll want to use:
^[a-zA-Z0-9 ]+$

Your RegEx disallows lower case. ;)

But yes, such RegEx will prevent Emoji. It also removes the possibility of punctuation.
Thanks to @wcbryant for indulging my curiosity and giving me some information about vBulletin that lead me to figuring out that both of our RegEx's will work in XenForo for the same reason his works in vBulletin. Its due to the fact that both vBulletin and XenForo utilize the Caseless flag in the RegEx.

You learn something new every day.
 

Blue

Well-known member
No. That will reject a decent amount of usernames. You'll want to use:
^[a-zA-Z0-9 ]+$

Your RegEx disallows lower case. ;)

But yes, such RegEx will prevent Emoji. It also removes the possibility of punctuation.
I've been using this.
^[a-z0-9]++(?:\s[a-z0-9]++)?$

The one you posted looks cleaner, much difference?
 

Blue

Well-known member
Not a RegEx master, that's @Mike. But a quick search of the Internet returned this for the double ++:
http://stackoverflow.com/questions/4489551/what-is-double-plus-in-regular-expressions

Probably not necessary in this case. Yours seems to enforce two words as a maximum of two words. Although you do use a non capturing group. I'll have to research it more tonight. Where did you get it?

However, mine does as it is stated above.
I think I got it here but I really don't remember.
 

arr0w

Member
Are there any real potential problems with allowing these type of chars or it's just to avoid its tackiness?
 

Jaxel

Well-known member
This is what I use:
Code:
^[A-Za-z0-9][\w\-\.\s]+[A-Za-z0-9]$
Must START/END with an alpha-numeric.
Can contain alpha-numeric, _ - . and space.
 
Top