How to guide only permits registration of usernames with the first letter capitalized for...

So I made with more letters another version:

/^[ÂÁÊÉÍÔÓÚÇA-Z][a-zA-ZâãáêéíôõóúçÂÁÃÊÉÍÔÓÕÚÇ0-9_-]*$/
with all accent, but I don't know why, lowercase is allowed at the beginning.
Are you certain you're using exactly that regex? I just tested it (externally, i.e. not in the XF ACP) and it wasn't matching names which start with a lowercase character. If yes, can you paste an example username that it permits?
 
Please try it

PHP:
/^[ÂÁÃÊÉÍÔÓÚÇA-Z][a-zÂáãêéíôóúç0-9_-]*$/

If it works as you expect, hit like!

Please utilize my code
This code does not allow users to have capital letters in the middle of their name. That's why I tried to make a new one that would give this possibility.


Are you certain you're using exactly that regex? I just tested it (externally, i.e. not in the XF ACP) and it wasn't matching names which start with a lowercase character. If yes, can you paste an example username that it permits?
I am using this:
PHP:
/^[ÂÁÊÉÍÔÓÚÇA-Z][a-zA-ZâãáêéíôõóúçÂÁÃÊÉÍÔÓÕÚÇ0-9_-]*$/

But the lowercase "â", as in the image, is still allowed. I found this strange because I thought the letters in the first brackets were the only ones allowed for the beginning of the name. :cry:
1717862956123.webp
 
I thought the letters in the first brackets were the only ones allowed for the beginning of the name. :cry:
Yes, that's what the regex indicates.

I just tried this in the ACP myself and it didn't work. So far I can't get ANY regex in the "Username match regular expression" to make any difference to the accepted usernames... o_O (edit: belay that, just realised I had an issue with my test)
 
Last edited:
But the lowercase "â", as in the image, is still allowed.
OK I corrected my mistake and managed to both reproduce this and find a cure.
Turns out you need to add the 'u' flag at the end of the RE, e.g. /^[ÂÁÊÉÍÔÓÚÇA-Z][a-zA-ZâãáêéíôõóúçÂÁÃÊÉÍÔÓÕÚÇ0-9_-]*$/u (y)
 
OK I corrected my mistake and managed to both reproduce this and find a cure.
Turns out you need to add the 'u' flag at the end of the RE, e.g. /^[ÂÁÊÉÍÔÓÚÇA-Z][a-zA-ZâãáêéíôõóúçÂÁÃÊÉÍÔÓÕÚÇ0-9_-]*$/u (y)
Ooh! I'll try it.
 
How to guide only permits registration of usernames with the first letter capitalized for XenForo - It only allows characters from a to z, digits from 0 to 9, hyphens, and dashes.
I use /^[\w ]+$/ which works well and achieves the same.
 
Back
Top Bottom