《判断字符串是否在字符串中,取想要的字符串》
2021-03-17 本文已影响0人
失忆的程序员
NSString *strttt = @"http://source.hahaha66.cn/1615946279.png";
if ([strttt localizedCaseInsensitiveContainsString:@"cn/"])
{
if ([strttt localizedCaseInsensitiveContainsString:@".png"])
{
NSRange startRange = [strttt rangeOfString:@"cn/"];
NSRange endRange = [strttt rangeOfString:@".png"];
NSRange range = NSMakeRange(startRange.location + startRange.length, endRange.location - startRange.location - startRange.length);
NSString *result = [strttt substringWithRange:range];
XPFLog(@" ===== %@ ", result);
}
}
else
{
XPFLog(@" 失败 ");
}