iOS去除字符串中的换行符

NSString *str = "/r/n你好吗";
str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //去除掉首尾的空白字符和换行字符
str = [str stringByReplacingOccurrencesOfString:@"\r" withString:@""];
str = [str stringByReplacingOccurrencesOfString:@"\n" withString:@""];

posted @ 2018-04-04 11:34  Zsmile  阅读(938)  评论(0编辑  收藏  举报

屛去雕饰,反近自然。