XF 2.1 Issue with "Username match a regular expression" field in Registration options

Max Fridman

Well-known member

Im trying to configure my forum to stop users from using special alphabets and special characters using the "Username match a regular expression" field in the registration options but if i put something like this: [A-Za-z0-9 -_]

The forum just stops accepting everykind of username and people cant register, how the regular expression should be written? To let only regular characters, Aa , numbers and spaces or underscores?

Thanks for the reply.


XenForo moderator
Staff member
Try this: /^[a-z0-9 -]+$/i

That will allow letters, numbers, spaces and -.
Remove everything after the 9 inside the ] if you don't want spaces and -.