ios在字符串中截取特定值

NSString *start = [NSString stringWithFormat:@"要截取的字符串之前的值"];
NSString *end = [NSString stringWithFormat:@"要截取的字符串之后的值"];
                
NSRange starRange = [str rangeOfString:start];
NSRange endRange = [str rangeOfString:end];
NSRange range = NSMakeRange(starRange.location + starRange.length, endRange.location - starRange.location - starRange.length);

NSString *resultStr = [str substringWithRange:range];

// 将字符串通过判断固定的值分离成数组
NSArray *array = [resultStr componentsSeparatedByString:@"要判断的值"];

你可能感兴趣的:(ios在字符串中截取特定值)