我有一个字符串“嗨,你好吗?
我想在你之后和之前找到子串.
如何在客观c?
解决方法
找到两个字符串的范围并返回之间的子串:
NSString *s = @"hi how are... you"; NSRange r1 = [s rangeOfString:@"how"]; NSRange r2 = [s rangeOfString:@"you"]; NSRange rSub = NSMakeRange(r1.location + r1.length,r2.location - r1.location - r1.length); NSString *sub = [s substringWithRange:rSub];