XF 1.4 Username Regex Assistance

Zelkova

Member
Hello Xenforo Community!

I am trying to allow only alpha numeric + Hangul usernames on my site but I am not having any luck.

I am currently using the assistance of this thread to only allow alpha numeric
https://xenforo.com/community/threads/username-validation-regex.24291/

However upon trying to modify it to allow Hangul I am having a bit of trouble.

From what I understand \p{Hangul} should allow all Hangul characters.

How would I add it to my current expression? ^[a-zA-Z0-9]*$
 
The regex used doesn't actually appear to be matching in Unicode-aware mode, so unfortunately that \p{...} sequence won't actually match. It would require a code change, and it's possible this could adjust how the regex matches (particularly for matching byte patterns outside basic ASCII) so changing it in the core runs the risk of backwards compatibility breaks.

The only alternative I can see currently relates to matching the UTF-8 pattern for the characters or enforcing it via moderation.
 
I did some digging and I believe that these are the UTF-8 ranges for Hangul

u3130-u318F and uAC00-uD7AF

Would you mind assisting me with somehow getting these set up in regex?
 
I'm not 100% sure this is correct, but I've converted those ranges to UTF-8 and then done hex range matching and have come up with...

Code:
^([a-zA-Z0-9]|\xE3(\x84[\xB0-\xFF]|\x85.|\x86[\x00-\x8F])|\xEA(\xB0[\x80-\xFF]|[\xB1-\xFF].|\x9E[\xAF-\xFF])|[\xEB-\xEC]..|\xED([\x00-\x9D].|\x9E[\x00-\xAF]))+$
 
Top Bottom