先来说说判断方法,书写不简介但是好理解:
-(BOOL)isRealNmaeString:(NSString *)str{ NSString *pattern = @"填写正则表达式"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern]; BOOL isMatch = [pred evaluateWithObject:str]; if (str.length==0) { return NO; }else if (!isMatch) { return NO; }else { return YES; } }
1,只能输入中文:^[u4e00-u9fa5]+$
2,输入价格,如33.33 :^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$
3,验证手机号:1[3578][0-9]{9}$
持续更新中...