priore

Remove unused characters in a NSString

Mar 29th, 2013
570
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (NSString*)removeUnusedCharacters:(NSString*)input
  2. {
  3.     NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"ÀÁÂÃÄâãäàÈÉÊËêëÌÍÎÏîïíÒÓÔÕÖôõöóÙÚÛÜûüùÝýñ\\|!\"£$%&/=?^+*°#§;:_`«“‘¥~‹÷´`≠¡ˆ„Ω€®™æ¨œøπ[]åß∂ƒ∞∆ªº¬@¶≤≥<>∑†©√∫˜µ…•–◊{}±¿≈⁄›‰¢’”»ı³"];
  4.     return [[[input componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  5. }
RAW Paste Data