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