thi*_*y93 17 regex objective-c ios
所以我想我需要一个正则表达式声明才能做到这一点,但我还没有用目标c做任何正则表达式,而且我还没有在一年内编写正则表达式语句.
我认为应该是((?=.*[0-9]).{7,1000})
如何将其置于客观的c字符串比较中并评估结果?
我的正则表达式也正确吗?
rma*_*ddy 67
虽然正则表达式可能有效,但还有另一种方法:
NSString *str = // some string to check for at least one digit and a length of at least 7
if (str.length >= 7 && [str rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]].location != NSNotFound) {
    // this matches the criteria
}
此代码实际上检查的不仅仅是0-9.它也处理来自其他语言的数字.如果你真的只想要0-9然后替换:
[NSCharacterSet decimalDigitCharacterSet]
有:
[NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
| 归档时间: | 
 | 
| 查看次数: | 14992 次 | 
| 最近记录: |