ios - 检查子字符串是否在范围内

标签 ios

在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/

相关文章:

IOS在一个类中多次使用单个dispatch_group

ios - 如何更改导航栏高度

ios - 如何在iOS中将NSObject分配到其自己的虚拟内存页面上?

ios - Admob bannerView 请求错误 : No ad to show

ios - swift 。如何动态地将结果分成几个部分

iOS PhoneGap 相机无法将图像保存到照片库

ios - 在 Swift 中动画循环进度 View

ios - 如何在swift项目中导入objective c头文件

ios - 备份和恢复 realm.io 数据库

ios - 进入后台时 BLE 扫描停止?