zoukankan      html  css  js  c++  java
  • 递归获取字符串内的所有图片src地址

    // 递归调用获取字符串内所有的src地址

    -(NSMutableArray *)getImageSrcUrlWithString:(NSString *)str withArray:(NSMutableArray *)myArray

    {

        NSMutableString *sourceStr = [NSMutableString stringWithString:str];

        NSString *srcStartPatten= @"src="";

        NSString *srcEndPatten = @""";

        

        NSRange startRange = [sourceStr rangeOfString:srcStartPatten];

        if(startRange.location == NSNotFound)

        {

            return myArray;

        }

        

        int startIndex = (int)startRange.location;

        

        if(startIndex >= 0)

        {

            sourceStr = [sourceStr substringFromIndex:startIndex+5];

            NSRange endRange = [sourceStr rangeOfString:srcEndPatten];

            

            int endIndex = (int)endRange.location;

            

            if(endIndex >= 0)

            {

                NSString *src = [sourceStr substringToIndex:endIndex];

                [myArray addObject:src];

                

                NSString *leftStr = [sourceStr substringFromIndex:endIndex+3];

                [self getImageSrcUrlWithString:leftStr withArray:myArray];

            }

        }

        

        return myArray;

    }

  • 相关阅读:
    mysqldump全量和增量备份脚本
    mysqldump根据通配符批量导出
    xtrabackup2.4_MySQL5.7备份与恢复
    ArrayInt
    Oracle wallet配置登陆凭证
    percona xtrabackup8.0.4备份恢复mysql8.0.12
    mysql修改密码
    range
    一周感悟
    Target
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4922577.html
Copyright © 2011-2022 走看看