删除特定字符

/**
 *  删除特定字符
 *
 *  @param str 需要处理的字符串
 *
 *  @return 想要的结果
 */
- (NSString *)stringDeleteString:(NSString *)str
{
    NSMutableString *str1 = [NSMutableString stringWithString:str];
    for (int i = 0; i < str1.length; i++) {
        unichar c = [str1 characterAtIndex:i];
        NSRange range = NSMakeRange(i, 1);
//        if (|| c == '"' || c == '.' || c == ',' || c == '(' || c == ')') { //此处可以是任何字符
        if(c == '-'){
            [str1 deleteCharactersInRange:range];
            --i;
        }
    }
    NSString *newstr = [NSString stringWithString:str1];
    return newstr;
}

你可能感兴趣的:(删除特定字符)