3
votes

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.

2

2 Answers

2
votes

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).

2
votes

The following regular expression will limit your length and allow special characters.

^(?=.*\d)(?=.*[a-zA-Z]).{6,10}$