ios在字符串中截取特定值

2016-11-06  本文已影响0人  amoyb1ooooooo
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:@"要判断的值"];

上一篇 下一篇

猜你喜欢

热点阅读