iPhone中的密码正则表达式 [英] Regular Expression for password in iPhone

查看:111
本文介绍了iPhone中的密码正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建正则表达式时非常弱。所以我在这里。

I am pretty much weak in creating Regular Expression. So i am here.

我需要一个满足以下条件的正则表达式。

I need a regular expression satisfying the following.

NSString *nameRegex =@"My RegEx"; 
NSPredicate *nameTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", nameRegex]; 
validationResult=[nameTest evaluateWithObject:password];

这些是条件


  1. 它应该包含字母和数字

  1. It should contain letters and numbers

最少7个字符最多32个字符

Minimum 7 characters Max 32 characters

没有空间

没有符号

请帮助..

推荐答案

以下是你的表现!

不要忘记开始结束标记。

Don't forget the "beginning to end" markers.

对于记录,如果您希望字符串明确包含两个字母和数字,那么一个正则表达式无法做到这一点。 (事实上​​,在数学上你可以做到,但正则表达式将是巨大的。)

For the record, if you want it the string to definitely include both letters and digits, there is no way to do that with one regex. (In fact, mathematically you could do it, but the regex would be enormous.)

只需运行上面的检查,然后再检查它包含一个字母:/ [a-zA-Z] /

Simply run the above check, and THEN ALSO CHECK that it contains a letter: /[a-zA-Z]/

并且那么测试它包含一个数字:/ [0 -9] /

And THEN ALSO TEST that it contains a digit: /[0-9]/

这是最简单的方式。

这篇关于iPhone中的密码正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆