美文网首页
正则表达式语法

正则表达式语法

作者: zmjchuan | 来源:发表于2018-04-23 11:25 被阅读11次

原文链接
@"^[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];

相关文章

网友评论

      本文标题:正则表达式语法

      本文链接:https://www.haomeiwen.com/subject/ubmklftx.html