I want to check for a valid vimeo url
-(BOOL) validateUrl2: (NSString *) candidate2
{
NSString *urlRegEx2 = @"(https://vimeo.com/(channels/[a-zA-Z]+/){0,1}[0-9]+[?]{0,1}.*$))";
NSPredicate *urlTest2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx2];
urlCheck2 = [urlTest2 evaluateWithObject:candidate2];
return [urlTest2 evaluateWithObject:candidate2];
}
I am using above code but it's not working, i guess their is some issue with RegEx, can any one provide me with RegEx to check wether a url is valid vimeo url, basically i want to check wether url contains @"https://vimeo.com/anything".
-(BOOL) validateUrl2: (NSString *) urlString
{
NSString *urlRegEx2 = @"http://.*vimeo\\.com/.*/(\\s|$)";
NSPredicate *urlTest2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx2];
urlCheck2 = [urlTest2 evaluateWithObject:candidate2];
return [urlTest2 evaluateWithObject:candidate2];
}
Edit: I you just want to check if the URL is like @"https://vimeo.com/anything"
why the check the host?
-(BOOL) validateURLWithString: (NSString*)urlString {
NSURL* url = [NSURL URLWithString:urlString];
if ([url.host isEqualToString:@"vimeo.com"])
return YES;
return NO;
}
you can also check what is the scheme
[url.scheme isEqualToString:@"https"]