Expression for match those constraint and password:
- (NSString *) getRegularExpression: (NSString *) extraWords
{
/*
* ^$ Empty string
* | Or
* ^ Start of a string
* [] Explicit set of characters to match
* ^[:space:] Matches any non-white-space character - equivalent to \S
* {6,30} 6-20 characters
* $ End of a string
* (?=...)(?=...) And Operators
*/
// eg: @"^$|(?=^[^[:space:]]{6,20}$)(?=^password$)"
return [NSString stringWithFormat:@"^$|(?=^[^[:space:]]{6,20}$)(?=^%@$)", extraWords];
}
extraWords is for receiving password string.