首页 > 代码库 > HTTP的网址的验证

HTTP的网址的验证

 

代码:

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.        NSLog(@"---isUrl--%i--",[self isUrl:@"http://www.itjhwd.com/iosgyzz/"]);    }//用正则表达式- (BOOL)isUrl:(NSString *)url{    NSString *      regex = @"http(s)?:\\/\\/([\\w-]+\\.)+[\\w-]+(\\/[\\w- .\\/?%&=]*)?";    NSPredicate *   pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];        return [pred evaluateWithObject:url];}

 

 

输出:

 

2014-11-17 15:04:03.485 iOS网址验证[30377:60b] ---isUrl--1--

HTTP的网址的验证