iOS???????????????????
???????????? ???????[ 2014/8/6 11:34:18 ] ??????????????? ??????
//???????????????????????????????
NSString *urlString = @"sfdshttp://www.baidu.com";
NSError *error;
//http+:[^\s]* ??????????????????
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"http+:[^\s]*" options:0 error:&error];
if (regex != nil) {
NSTextCheckingResult *firstMatch = [regex firstMatchInString:urlString options:0 range:NSMakeRange(0?? [urlString length])];
if (firstMatch) {
NSRange resultRange = [firstMatch rangeAtIndex:0];
//??urlString?н??????
NSString *result = [urlString substringWithRange:resultRange];
NSLog(@"%@"??result);
}
}
?????????????
????[1302:403] http://www.baidu.com
??????????iOS??????????????????????????????????????
??????????????????????????÷???
????1.????NSPredicate??ν??????
?????????????Ч????
????NSString ??email ?? @“nijino_saki@163.com”??
????NSString *regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2??4}";
????NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@"?? regex];
????BOOL isValid = [predicate evaluateWithObject:email];
????ν???????????????????ν??????????
????2.????rangeOfString??option????????
????NSString *searchText = @"// Do any additional setup after loading the view?? typically from a nib.";
????NSRange range = [searchText rangeOfString:@"(?:[^??])*\." options:NSRegularExpressionSearch];
????if (range.location != NSNotFound) {
????NSLog(@"%@"?? [searchText substringWithRange:range]);
????}
????options???趨NSRegularExpressionSearch?????????????????????????????????λ?á?
????С??
?????????????????NSPredicate??д????????????????????????????????????????????????????????????????????????????????Σ?????????Ч???????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11