首页 > 代码库 > 按指定格式的子字符串,删除和分割字符串

按指定格式的子字符串,删除和分割字符串

删除就用
- (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement;
将@“[:1:]"”,替换成@“”

分割就用
- (NSArray *)componentsSeparatedByString:(NSString *)separator;
根据你选定分割符拆分字符串

 

IOS字符串按特定字符拆分成数组

NSString * fruits = @"apple,pair,banana,orange";

NSArray * array= [fruits componentsSeparatedByString:@","];