title: URL Validation function improving
body: <p>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!</p>
  
  <blockquote>
    <p><a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/11841-stringbytrimmingcharactersinset.html" rel="nofollow">http://www.iphonedevsdk.com/forum/iphone-sdk-development/11841-stringbytrimmingcharactersinset.html</a>  </p>
  </blockquote>
  
  <p>what can i do to improve the regular expression of my function that it will cover all URL types?</p>
  
  <pre><code>- (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];
  }
  </code></pre>