ios字符串截取

iOS NSString 截取字符串

怎甘沉沦 提交于 2020-02-02 08:25:45
1. rangeOfString:截取指定字符串的长度; 2. substringToIndex:7:截取从0 索引到指定索引(7)长度的字符串 3. substringFromIndex:9:截取从指定索引(9)到末尾长度的字符串 4. NSRange range = NSMakeRange(0,7);截取从指定索引(0)到指定(7)长度的字符串 5. substringWithRange:range:截取从指定索引(0)到指定(7)长度的字符串 6. isEqualToString:@"p://www":比较字符串包含关系,区分大小写 7. stringWithFormat:格式化字符串。 void findSubString(){ NSString *filename = @"config.ini"; NSString *escapedPath = @"/Users/config.ini"; //在escapedPath中查找filename //NSRange iStart = [escapedPath rangeOfString :filename]; NSRange iStart = [escapedPath rangeOfString: filename options:NSCaseInsensitiveSearch]; // NSLog(@"iStart