Fast question, i'm using NSPredicate
to verify passwords, I already use this code for the username:
-(BOOL)isUserValid:(NSString *)checkString{
NSString *filter = @"[A-Z0-9a-z]{5,40}";
NSPredicate *evaluator = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", filter];
return [evaluator evaluateWithObject:checkString];
}
But now on the password i would like to allow the user to use special characters such as "@", "$", "&", "*".
How can i do this?
I don't know you needs exactly how many characters or specified characters allow to user. but, according to your question example, if you want to allow the user only
@
,$
,&
,*
characters. refer a following code.following filter code is one of the popular password expreesion. alphanumeric characters and select special characters. The password also can not start with a digit, underscore or special character and must contain at least one digit.
and more expression filter about password. see the site: regexlib_password
following reference is You'll help while you are working. and remember a following Expression about Character and Bracket.