1.去掉字符串两端的空格及回车
- (NSString *)removeSpaceAndNewline:(NSString *)str{
NSString *temp = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *text = [temp stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet ]];
return text;
}
2.去掉所有的空格及字符串
- (NSString *)removeSpaceAndNewline:(NSString *)str{
NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];
temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];
return temp;
}