一些正则表达式以及objective-c下边的正则判断:
Require : /.+/, Email : /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/, Phone : /^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/, Mobile : /^((\(\d{3}\))|(\d{3}\-))?13\d{9}$/, Url : /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>""])*$/, IdCard : /^\d{15}(\d{2}[A-Za-z0-9])?$/, Currency : /^\d+(\.\d+)?$/, Number : /^\d+$/, Zip : /^[1-9]\d{5}$/, QQ : /^[1-9]\d{4,8}$/, Integer : /^[-\+]?\d+$/, Double : /^[-\+]?\d+(\.\d+)?$/, English : /^[A-Za-z]+$/, Chinese : /^[\u0391-\uFFE5]+$/, UnSafe :/^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'"]*)|.{0,5})$|\s/,
//验证码4位 -(BOOL)VerCaptchaByFour { NSString *pattern = @"\\d{4}"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern]; return [pred evaluateWithObject:self]; } //验证码6位 -(BOOL)VerCaptchaBySix { NSString *pattern = @"\\d{6}"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern]; return [pred evaluateWithObject:self]; } //验证手机号 -(BOOL)VerPhoneNumber { NSString *pattern = @"^1+[3578]+\\d{9}"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern]; return [pred evaluateWithObject:self]; } //验证邮箱 -(BOOL)VerEmail { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; return [emailTest evaluateWithObject:self]; } //验证密码6-20 -(BOOL)VerPassword { NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z]|[0-9]|[a-zA-Z0-9]{6,20}"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern]; return [pred evaluateWithObject:self]; }