1.截取字符串
NSString *string =@"123456d890";
NSString *str1 = [string substringToIndex:5];//截取掉下标5之前的字符串
NSLog(@"截取的值为:%@",str1);
 NSString *str2 = [string substringFromIndex:3];//截取掉下标3之后的字符串
NSLog(@"截取的值为:%@",str2);
2.匹配字符串
NSString *string =@"sd是sfsfsAdfsdf";
NSRange range = [string rangeOfString:@"Ad"];//匹配得到的下标
NSLog(@"rang:%@",NSStringFromRange(range));
string = [string substringWithRange:range];//截取范围内的字符串
NSLog(@"截取的值为:%@",string);
3.分隔字符串
NSString *string =@"sdfsfsfsAdfsdf";

NSArray *array = [string componentsSeparatedByString:@"A"]; //从字符A中分隔成2个元素的数组
NSLog(@"array:%@",array); //结果是adfsfsfs和dfsdf

//用一段字符串 替换一段字符串
NSString *strUrl = [urlString stringByReplacingOccurrencesOfString:@“;" withString:@""];
//替换某段字符
NSString *idCard = [Str stringByReplacingCharactersInRange:NSMakeRange(5, 6) withString:@"*****************"];
NSLog(@"idCard:%@",idCard);
4.字母大小写转换

NSString  *str =@"AAaaBB3bb";
// 把字符串全部转化为小写
NSString *str1 = [str lowercaseString];
NSString * str2 = str.lowercaseString;

// 把字符串全部转化为大写(里面包含数字没事)
str1 = [str uppercaseString];
str2 = str.uppercaseString;

//开头大写,其余小写(里面包含数字,数字后的字母会大写)
str1 =[str capitalizedString];
str2 =str.capitalizedString;

DLog(@"%@ - %@",str1, str2);
03-05 15:33