//去除掉首尾的空白字符和换行字符
NSString * originalString = subTitle; // 想要过滤的字符串
NSLog(@"过滤前---%@",originalString);
// 去掉首尾的空白字符
originalString = [originalStringstringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]];
// 去掉换行符
originalString = [originalStringstringByReplacingOccurrencesOfString:@"\r"withString:@""];
originalString = [originalStringstringByReplacingOccurrencesOfString:@"\n"withString:@""];
originalString = [originalStringstringByReplacingOccurrencesOfString:@"\t"withString:@""];
// originalString 过滤后的字符串
NSLog(@"过滤后---%@",originalString);
网友评论