How would you create a regular expression for a value that should contain at least one number? The user can enter any special character, letter etc., but should contain at l
Try using this pattern
.*[0-9].*
For 6 to 20 use this
^(?=.*\d).{6,20}$
You can use this pattern:
/^(?=.{6,20}$)\D*\d/
Use this Regex
An easier solution would be to retain your existing regex, then create two new regexes to test for your "at least one alphabetic" and "at least one numeric".
So, test for this :-
/^([a-zA-Z0-9]+)$/
Then this :-
/\d{1}/
Then this :-
/[A-Z]{1}/i