- (BOOL) isValidatePassword:(NSString *)str
{ //以字母开头,只能包含“字母”,“数字”,长度6~18
NSString *regex = @"^([a-zA-Z]|[a-zA-Z0-9]|[0-9]){6,18}$";
NSPredicate *ipv4Regx = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [ipv4Regx evaluateWithObject:str];
}
/// 是否ipv6合法
/// @param mobile 字符串地址
- (BOOL)isIPV4Validate:(NSString *)str {
NSString *regex = @"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$";
NSPredicate *ipv6Regx = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
return [ipv6Regx evaluateWithObject:str];
}
网友评论