zoukankan      html  css  js  c++  java
  • NSString 特殊字符

    /*
     函数描述:字符串筛选,去掉不需要的特殊字符串
     参数描述:target         原字符串
             replacement   需要替换的字符串
             options       默认传2:NSLiteralSearch,区分大小写
             _replaceArray 需要排除的Array
     返回值: 筛选完的String
     备注:   使用方法:replaceOccurrencesOfString:@"1(2*3" withString:@"" options:2 replaceArray:[NSArray arrayWithObjects:@"(",@"*", nil]
     输出:123
     */
    + (NSString *)replaceOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options replaceArray:(NSArray *)_replaceArray {
        NSMutableString *tempStr = [NSMutableString stringWithString:target];
        NSArray *replaceArray = [NSArray arrayWithArray:_replaceArray];
        for(int i = 0; i < [replaceArray count]; i++){
            NSRange range = [target rangeOfString: [replaceArray objectAtIndex:i]];
            if(range.location != NSNotFound){
                [tempStr replaceOccurrencesOfString: [replaceArray objectAtIndex:i]
                                         withString: replacement
                                            options: options
                                              range: NSMakeRange(0, [tempStr length])];
            }
        }
        return tempStr;
    }

    日志地址:http://www.cnblogs.com/maxfong/archive/2013/01/28/2880672.html

  • 相关阅读:
    如果你很忙,你一定在什么地方做错了!
    NOSQL介绍
    mysql 8.0.11 安装(windows)
    ORA-28547:(Navicat Premium连接oracle报错)
    线性筛法
    Luogu-P1020(导弹拦截)(DP,LIS ,二分优化)
    POJ
    HDU
    HDU-1024-Max Sum Plus Plus(DP)
    UVA-1625-Color Length(DP LCS变形)
  • 原文地址:https://www.cnblogs.com/maxfong/p/2880672.html
Copyright © 2011-2022 走看看