iSuresh iSuresh - 1 month ago 13
iOS Question

Regular Expression for Password Validation Objective-C

Can anyone Please Help me i need a regular expression Password Validation.

Condition : Password should be maximum of 8 characters numeric or alphabetic with atleast one special characters

Thanks in advance.

Answer
^(?=.{2,8}$)(?=.*?[A-Za-z0-9])(?=.*?[\W_])[\w\W]+

This regular expression allowes 2 to 8 character passwords. It requires to have at least 1 alphanumeric (letter/number) character and 1 non-alphanumeric character. You can test it here.

If you want to change the minimum characters required or higher the maximum. Just change the 2 or 8.