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

XF 1.5 Regex for 5 different characters

Alfa1

Well-known member
#1
I want to force my members to type at least 5 different characters in a custom user field. Is there a regex statement I can use?
 

tenants

Well-known member
#2
Give this a go

/^[a-zA-Z0-9 ]{5,}$/

or

^[a-zA-Z0-9 ]{5,}$

Tested here https://regex101.com/r/sN7tX4/4

matches alphanumeric (and space), must match 5 or more times before the end of the string

Test it, I'm just guessing, I haven't used regex on custom fields, and regex isn't my strongest point (it drives me crazy)
 
Last edited:

Xon

Well-known member
#3
This doesn't prevent character re-use, but that quickly becomes an insane regex (but should be vaguely doable with backreferences)
 

EQnoble

Well-known member
#4
I want to force my members to type at least 5 different characters in a custom user field. Is there a regex statement I can use?
What is the exact formula you need.

Is what you wrote the only considerations, what are the limitations for characters (alpha, numeric, are they case sensitive where "A" and "a" are different)?