Reputation:
I need a regular expression which should have at least one numeric character, both uper and lower case letters allowed, special characters also allowed I am using this expression
/^.*(?=.{6,10})(?=.*\d)(?=.*[a-zA-Z]).*$
but it is not valid for max characters 10.
Upvotes: 3
Views: 4560
Reputation: 1
^(?=.{8,})(?=.+\d)(?=.+[A-Za-z])(?=.+\W).*$
Upvotes: 0
Reputation: 70732
The following regular expression will limit your length and allow special characters.
^(?=.*\d)(?=.*[a-zA-Z]).{6,10}$
Upvotes: 2
Reputation: 174776
Seems like you want something like this,
^(?=.*\d)(?=.*?[a-zA-Z])(?=.*?[\W_]).{6,10}$
The above regex would allow 6 to 10 characters only. And it also checks for at-least one digit, upper or lowercase letter and at-least one special character (characters other than letters and numbers).
Upvotes: 2