原文链接
@"^[1][34578][0-9]{9}$" :开头是1 ,中间是3/4/5/7/8
{9}9位 [0-9]0到9 数字的组合
“ab{4}”:表示一个字符串有一个a跟着4个b(”abbbb”);
NSString *phoneRegex = @"^[1][34578][0-9]{9}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
BOOL result = [phoneTest evaluateWithObject:mobile];
网友评论