开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜