问题描述
|
在iOS中,
Given an URL https://whateverthisisanurl.google.com/helloworld
如果我想测试//和/之间的google是否存在,那么有什么好方法?
解决方法
尝试这个
NSString *mystring = @\"https://whateverthisisanurl.google.com/helloworld\";
NSString *regex = @\".*?//.*?\\\\.google\\\\..*?/.*?\";
NSPredicate *regextest = [NSPredicate
predicateWithFormat:@\"SELF MATCHES %@\",regex];
if ([regextest evaluateWithObject:mystring] == YES) {
NSLog(@\"Match!\");
} else {
NSLog(@\"No match!\");
}