iOS开发之字符串去掉首尾空格换行
(1)去掉字符串首尾空格的方法:
NSString *str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
(2)去掉字符串首尾换行的方法:
NSString *str = [str stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
(3)去掉字符串首尾空格和换行的方法:
NSString *str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
(4)替换字符串内所有空格的方法:
NSString *str = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
(5)替换字符串内所有空格的方法:
NSString *str = [str stringByReplacingOccurrencesOfString:@"\n" withString:@""];
相关推荐
AllenG 2013-07-07
zhujiangtaotaise 2020-01-01
84407518 2012-07-16
Beatopcoder 2013-07-14
afrtooylsw 2014-05-14
让编程改变世界 2015-03-13
shqhope 2015-04-09
zoutian00 2015-05-12
87214552 2015-10-27
84407518 2016-01-25
89283517 2012-06-19
ObjectiveC 2012-06-14
huangshm 2019-01-14
86981633 2019-06-29
我的iOS王者之路 2019-06-28
好好学习天天 2019-06-28
jscjxysx 2019-06-28