-(BOOL)validateUrl{// NSString *urlRegEx = @"((?:http|https)://)?(www\\.)[\\w\\d\\-_]+\\.\\w{2,3}(\\.\\w{2})?(/(?<=/)(?:[\\w\\d\\-./_]+)?)?"; NSString *urlRegEx = @"((?:http|https)://)?(www\\.)[\\w\\d\\-_]+\\.\\w{2,3}(\\.\\w{2})?(/(?<=/)(?:[\\w\\d\\-./_]+)?)?"; NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx]; if ([urlTest evaluateWithObject: self] == YES) { NSLog(@"URL is valid!"); } else { NSLog(@"URL is not valid!"); } return [urlTest evaluateWithObject:self];}
↧
Answer by Kiran Bhoraniya for URL Validation function improving
↧