正则表达式总结
验证数字:^[0-9]*
验证数字和小数点:^[0-9]+([.]{0}|[.]{1}[0-9]+)
验证电话号码及手机:(d{3}-d{8}|d{4}-d{7})|(^(((d{3}))|(d{3}-))?13d{9}|15[89]d{8}
//正则 html NSString *verCodeRegex = @"[<A|a]{2}[s>)](.*?)[</A|a>]{4}";
NSPredicate *verCodePredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",verCodeRegex];
if ([verCodePredicate evaluateWithObject:systemContent]) {
}
//使用方式 写个简单的方法 - (BOOL)checkNum:(NSString *)str
{
NSString *regex = @"^[0-9]*$";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
BOOL isMatch = [pred evaluateWithObject:str];
if (!isMatch) {
remind = [[UIAlertView alloc] initWithTitle:@"提示" message:@"亲,只能输入数字哦" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定",nil];
remind.delegate = self;
[remind show];
return NO;
}
return YES;
}
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |