Quantcast
Channel: URL Validation function improving - Stack Overflow
Viewing all articles
Browse latest Browse all 6

URL Validation function improving

$
0
0

i use this function to check if an URL is valid or not. it works for most of the cases, but here the following URL it return that is not Valid!

http://www.iphonedevsdk.com/forum/iphone-sdk-development/11841-stringbytrimmingcharactersinset.html

what can i do to improve the regular expression of my function that it will cover all URL types?

- (BOOL) urlIsValiad: (NSString *) url {    NSString *regex =     @"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";    NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];    if ([regextest evaluateWithObject: url] == YES) {        NSLog(@"URL is valid!");    } else {        NSLog(@"URL is not valid!");    }    return [regextest evaluateWithObject:url];}

Viewing all articles
Browse latest Browse all 6

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>