my requirement is to match a regex with at least one alphabet[a-z], at least one number[0-9] and at least any symbols eg(~`!@#$%^&*()-_ ={}[]|;:"<>,./?)
valid :
- blog@123
- 12#code
- $$455hi
not valid :
- blog123
- 1223
- blog
CodePudding user response:
Use lookaheads to be sure the string includes the required characters:
^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[~`!@#$%^&*()_ ={}[\]|;:"<>,.\/?-]).*$
Also don't forget to escape ]
and /
.