在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!");
}
关于ios - 检查子字符串是否在范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6191089/