gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:27:24 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com