How do I create a regular expression of minimum 8, maximum 16, alphabetic, numbers and NO space?
^[a-zA-Z0-9]{8,16}$
You can specify the minimum/maximum gathered using {X,Y} as the boundaries.
Other examples:
^[a-zA-Z0-9]{8,}$
#8 or more characters
^[a-zA-Z0-9]{,16}$
#Less than or equal to 16 characters
^[a-zA-Z0-9]{8}$
#Exactly 8 characters
Regex cheatsheet
You just need to put bounds on, not the + (one or more) operator.
^[a-zA-Z0-9]{8,16}$
^[A-Za-z0-9]{8,16}$
Specify a min/max length for a part of an expression using {x,y}
, where x
is the minimum and y
is the maximum.