phoneNumber正则表达式

来源:互联网 发布:淘宝亏本卖 编辑:程序博客网 时间:2024/05/21 17:07
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; }