NSString *zhengze=@"^([a-z0-9]+\\.?(?:com|cn|mobi|co|net|so|org|gov|tel|tv|biz|cc|hk|name|info|asia|me)?(?:\\.?(?:cn))?)$";
NSPredicate *pre=[NSPredicatepredicateWithFormat:@"SELF MATCHES %@",zhengze];
if (![pre evaluateWithObject:searchText.text]) {
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:nilmessage:@"对不起,您输入的域名格式有误\n请重新输入!\n\n例如:abc/abc.com" delegate:self cancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
[alert show];
[alert release];
searchText.text=@"";
}
NSString *match =@"^([a-z0-9]*[\u4e00-\u9fa5]+[a-z0-9]*\\.?(?:com|net|tv|biz|cc|公司|网络|中国)?)$";
NSPredicate *predicate = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",match];
if(![predicate evaluateWithObject:textField.text]){
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:nilmessage:@"对不起,您输入的域名格式有误\n请重新输入!\n\n例如:万网/万网.com" delegate:self cancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
[alert show];
[alert release];
}
searchText.text=@"";
}