2014-06-07 4 views
0

이 코드를 사용하여이 방법으로 내 attributedString을 필터링하려고합니다. 그러나 rangeOfCharacterFromSet:에 "@"기호 이외의 모든 원래 값을 포함 시키길 원합니다. 어떻게하면 좋을까요?punctuationCharacterSet에서 "@"기호 제외

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

답변

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];