美文网首页
NSCharacterSet

NSCharacterSet

作者: 一代骄马 | 来源:发表于2018-05-05 17:25 被阅读25次

iOS中NSCharacterSet的使用详解 - CSDN博客 

在不同的字符上做过滤、

if( [strPath rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"/\\"]].location!=NSNotFound )

/例子1:去除两边的空格  

 string =  [stringstringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];  

//过滤一些字符

 NSString *string = @"123a bc 9ABC";

 NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:NUM] invertedSet];         NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];

相关文章

网友评论

      本文标题:NSCharacterSet

      本文链接:https://www.haomeiwen.com/subject/ifderftx.html