我正在尝试使用此代码以这种方式过滤我的attributionString。但是,我希望rangeOfCharacterFromSet:
包含" @"的所有原始值除外。标志。我该怎么做?
NSRange rangeSpace = [filteredText rangeOfCharacterFromSet:[NSCharacterSet punctuationCharacterSet] options:NSCaseInsensitiveSearch range:NSMakeRange(range.location, filteredText.length - range.location)];
答案 0 :(得分:1)
NSMutableCharacterSet *punctuationSet = [NSMutableCharacterSet punctuationCharacterSet];
[punctuationSet removeCharactersInString:@"@"];
NSRange searchRange = NSMakeRange(range.location, filteredText.length - range.location)
NSRange rangeSpace = [filteredText rangeOfCharacterFromSet:punctuationSet
options:NSCaseInsensitiveSearch
range:searchRange];