NSString * regex = @”^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$”; NSPredicate * pred = [NSPredicate
predicateWithFormat:@"SELF MATCHES %@", regex]; BOOL isMatch = [pred evaluateWithObject:self.txt_cellphone.text]; if (!isMatch) { [txt_cellphone becomeFirstResponder]; return; }
phoneNumber正则表达式
最新推荐文章于 2025-04-24 00:30:00 发布
本文介绍了一段用于验证中国手机号码格式的Objective-C代码示例。通过使用正则表达式和NSPredicate,该方法能够准确判断输入的字符串是否符合中国大陆手机号的标准格式。
10万+

被折叠的 条评论
为什么被折叠?



