// 手机号验证正则表达式
1 func validateMobile(phoneNum:String)-> Bool { 2 3 // 手机号以 13 14 15 18 开头 八个 \d 数字字符 4 5 let phoneRegex = "^((13[0-9])|(17[0-9])|(14[^4,\\D])|(15[^4,\\D])|(18[0-9]))\\d{8}$|^1(7[0-9])\\d{8}$"; 6 7 let phoneTest = NSPredicate(format: "SELF MATCHES %@" , phoneRegex) 8 9 return (phoneTest.evaluateWithObject(phoneNum)); 10 11 }
时间: 2024-10-11 12:15:59