标签:character sch enc nbsp cin min har and 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:@""];
标签:character sch enc nbsp cin min har and ios开发
原文地址:https://www.cnblogs.com/hecanlin/p/12165846.html