取html文件里字符串最快的方法

2019-05-18  本文已影响0人  shushuzhen
+ (NSArray *)removeSymbolFromString:(NSString *)string{

    NSArray *arr = @[];
 
    if (!string || [string isEqualToString:@""]) {
        return [@[]mutableCopy];
    }
    
    NSScanner * scanner = [NSScanner scannerWithString:string];
    NSString * text = nil;
    while([scanner isAtEnd] == NO)
    {
        //找到标签的起始位置
        [scanner scanUpToString:@"<" intoString:nil];
        //找到标签的结束位置
        [scanner scanUpToString:@">" intoString:&text];
        //替换字符
        string  =  [string  stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>",text] withString:@"||"];
        arr  = [string componentsSeparatedByString:@"||"];
        
    }
    return arr;
}

上一篇 下一篇

猜你喜欢

热点阅读