IOS 去除空格
作者:
柠檬草YF | 来源:发表于
2018-05-31 11:28 被阅读454次-(NSString )getSeparatedPhoneNumberWithString:(NSString )phoneString { NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"];
NSString * string = phoneString;
//invertedSet方法是去反字符,把所有的除了characterSet里的字符都找出来(包含去空格功能)
NSCharacterSet *specCharacterSet = [characterSet invertedSet];
NSArray * strArr = [string componentsSeparatedByCharactersInSet:specCharacterSet];
return [strArr componentsJoinedByString:@""];
}
本文标题:IOS 去除空格
本文链接:https://www.haomeiwen.com/subject/gucqsftx.html
网友评论