Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:46
Show Gist options
  • Save priore/7163541 to your computer and use it in GitHub Desktop.
Save priore/7163541 to your computer and use it in GitHub Desktop.
Remove unused characters in a NSString
- (NSString*)removeUnusedCharacters:(NSString*)input
{
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"ÀÁÂÃÄâãäàÈÉÊËêëÌÍÎÏîïíÒÓÔÕÖôõöóÙÚÛÜûüùÝýñ\\|!\"£$%&/=?^+*°#§;:_`«“‘¥~‹÷´`≠¡ˆ„Ω€®™æ¨œøπ[]åß∂ƒ∞∆ªº¬@¶≤≥<>∑†©√∫˜µ…•–◊{}±¿≈⁄›‰¢’”»ı³"];
return [[[input componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment