当前位置:编程学习 > wap >>

NSString去掉换行符和空白字符

NSString* headerData=***;
headerData = [headerData stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];  //去除掉首尾的空白字符和换行字符
       headerData = [headerData stringByReplacingOccurrencesOfString:@"\r" withString:@""];
       headerData = [headerData stringByReplacingOccurrencesOfString:@"\n" withString:@""];
如此即可。
补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,