NSRegularExpression usage in iOS
I'm looking for usage of regular expression in my user input string for presence of the following: - atleast one characte开发者_JS百科r in uppercase - atleast one numberic character - atleast 8 characters wide.
Any help would be appreciated.
Thanks
Try this (probably ascii only):
(?=.*[A-Z])(?=.*[0-9]).{8,}
or the Unicode variant (which, according the docs, should be supported):
(?=.*\p{Lu})(?=.*\p{Nd}).{8,}
Meaning:
(?=.*[A-Z]) # an upper case, anywhere in the string (or \p{Lu})
(?=.*[0-9]) # a digit, anywhere in the string (or \p{Nd})
.{8,} # 8 or more chars
精彩评论