• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

New forum member has username with emoji

Jeremy

Well-known member
#7
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.
 

wcbryant

Active member
#10
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
#12
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
#15
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
#17
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.
 

Jaxel

Well-known member
#19
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.