1 |
NSString * regex = @ "(^[A-Za-z0-9]{6,15}$)" ; |
2 | NSPredicate * pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@" ,regex]; |
3 | BOOL isMatch = [pred evaluateWithObject:@ "123456ABCde" ]; |
01 | 下面是一些常用的正则表达式 |
02 | //邮箱 |
03 | + () validateEmail:(NSString *)email |
04 | { |
05 |
NSString *emailRegex = @ "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" 06 |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@
|