iOS去掉字符串中的空格,换行符号
去掉空格和换行符号的实质就是替换掉对应的字符
NSString* str=~~~~~~; //1. 去除掉首尾的空白字符和换行字符 str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //2. 去除掉其它位置的空白字符和换行字符 str = [str stringByReplacingOccurrencesOfString:@"\r" withString:@""]; str = [str stringByReplacingOccurrencesOfString:@"\n" withString:@""];
文章来自:http://my.oschina.net/shoutan/blog/513702