0

我正在尝试使用此代码以这种方式过滤我的属性字符串。但是,我希望rangeOfCharacterFromSet:包含其所有原始值,“@”符号除外。我该怎么做?

NSRange rangeSpace = [filteredText rangeOfCharacterFromSet:[NSCharacterSet punctuationCharacterSet] options:NSCaseInsensitiveSearch range:NSMakeRange(range.location, filteredText.length - range.location)];
4

1 回答 1

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];
于 2014-06-07T13:15:11.160 回答