Objective-c: 移除字符串中的指定字符

string = [[string componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"  z/-"]] componentsJoinedByString:@""];

示例:

NSString *string = @"6225-021 xyz1234/";
NSString *afterString = [[string componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"  z/-"]] componentsJoinedByString:@""];
NSLog(@"before:%@, after:%@", string, afterString);

2014-02-28 15:19:12.626 XiaoJiZhuoMi[6188:a0b] before:6225-021 xyz1234/, after:6225021xy1234
原文地址:https://www.cnblogs.com/ihojin/p/remove-character-in-string.html