NSCharacterSet

NSCharacterSet其实是许多字符或者数字或者符号的组合,在网络处理的时候会用到

 

//
+ (NSCharacterSet *)controlCharacterSet;
//空格
+ (NSCharacterSet *)whitespaceCharacterSet;
//换行符和空格
+ (NSCharacterSet *)whitespaceAndNewlineCharacterSet;
//十进制数字
+ (NSCharacterSet *)decimalDigitCharacterSet;
//字母
+ (NSCharacterSet *)letterCharacterSet;
//小写字母
+ (NSCharacterSet *)lowercaseLetterCharacterSet;
//大写字母
+ (NSCharacterSet *)uppercaseLetterCharacterSet;
//没有基础的
+ (NSCharacterSet *)nonBaseCharacterSet;
//字母数字
+ (NSCharacterSet *)alphanumericCharacterSet;
//可分解的
+ (NSCharacterSet *)decomposableCharacterSet;
//非法
+ (NSCharacterSet *)illegalCharacterSet;
//标点符号
+ (NSCharacterSet *)punctuationCharacterSet;
//大写字母
+ (NSCharacterSet *)capitalizedLetterCharacterSet;
//象征
+ (NSCharacterSet *)symbolCharacterSet;
//换行符
+ (NSCharacterSet *)newlineCharacterSet NS_AVAILABLE(10_5, 2_0); + (NSCharacterSet *)characterSetWithRange:(NSRange)aRange; + (NSCharacterSet *)characterSetWithCharactersInString:(NSString *)aString; + (NSCharacterSet *)characterSetWithBitmapRepresentation:(NSData *)data; + (nullable NSCharacterSet *)characterSetWithContentsOfFile:(NSString *)fName; - (instancetype) initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;

 使用:

    NSMutableCharacterSet *base = [NSMutableCharacterSet letterCharacterSet]; //字母
    NSString *str = [[@"123123aasdasdasAAAA" componentsSeparatedByCharactersInSet:base]componentsJoinedByString:@"-----"];
    NSLog(@"%@\n%@",[@"123123aasdasdasAAA" stringByTrimmingCharactersInSet:base],[@"123123aaAAAsdasdas" componentsSeparatedByCharactersInSet:base]);
    NSLog(@"%@",str);

 

posted @ 2016-04-14 16:47  幻想无极  阅读(529)  评论(0编辑  收藏  举报