[IOS]NSMutableString字符替换

阅读更多

1.特定位置替换:

NSMutableString *tempString = [inputText mutableCopy];
    NSRange range = [inputText rangeOfString:@":"];
    if (range.length != 0) {
        [tempString replaceCharactersInRange:range withString:@""];
    }

 

2.全部替换:

NSMutableString *tempString = [inputText mutableCopy];
    NSRange range = NSMakeRange(0, [tempString length]);
    [tempString replaceOccurrencesOfString:@":" withString:@"" options:NSCaseInsensitiveSearch range:range];

 

你可能感兴趣的:(NSMutableString)