iOS中的NSRegularExpression用法

时间:2011-03-30 10:10:34

标签: iphone regex ipad

我正在寻找在我的用户输入字符串中使用正则表达式以获取以下内容: - 至少一个大写字母 - 至少一个数字角色 - 至少8个字符宽。

任何帮助都将不胜感激。

由于

1 个答案:

答案 0 :(得分:2)

试试这个(可能只是ascii):

(?=.*[A-Z])(?=.*[0-9]).{8,}

或Unicode变体(应支持according the docs):

(?=.*\p{Lu})(?=.*\p{Nd}).{8,}

含义:

(?=.*[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
相关问题