zoukankan      html  css  js  c++  java
  • swift 批量 取出中间文本

        func stringmid_pl (wholestring:String,front:String,behind:String,inout return_string:String,getheroid:Bool)

            

        {

            //数组参数inout

           

            // var whole_tmp:String = wholestring

            

     

            

            if wholestring.isEmpty

            {

               // return(return_string) //wholestring 不能为nil

                

            }else  {

                

                var whole:NSString=wholestring

                var whole_tmp = whole

               

                

                let frontindex = whole.rangeOfString(front)

                if frontindex.length > 0

                {

                    whole = whole.substringFromIndex(frontindex.location + frontindex.length)

                    let behindindex = whole.rangeOfString(behind)

                    if behindindex.length > 0

                    {

                        whole = whole.substringToIndex(behindindex.location)

                        

                        return_string = return_string + (whole as String) + ","

                        

    //                  whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front, withString: "", options: NSStringCompareOptions.LiteralSearch, range: frontindex)

    //                    

    //                  whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(behind, withString: "", options: NSStringCompareOptions.LiteralSearch, range: whole_tmp.rangeOfString(behind))

                        

                        

                      whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front + (whole as String) + behind, withString: "")

                     if getheroid == true

                     {

                        whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front + (whole as String), withString: "")

                        }

                    

                        

                    stringmid_pl(whole_tmp as String, front: front, behind: behind, return_string: &return_string,getheroid:getheroid)

                        

                        

                       // return(whole as String)

                        

                    } else {

                       // return(return_string)

                    } //没有找到behindwholestring

                    

                    

                } else  {

                    //return(return_string)

                }  // 没有找到front wholestring

            

            

            

            

        

        }

        

        

        

     

     

        

    }

  • 相关阅读:
    关于两次fork
    阻塞非阻塞与同步异步的区别
    函数调用堆栈
    数组
    64位操作系统与32位操作系统数据类型的字节数
    Redis 键(key)
    Redis 命令
    Redis 安装
    Redis 配置
    MongoDB 安装
  • 原文地址:https://www.cnblogs.com/youyaoqi/p/5486651.html
Copyright © 2011-2022 走看看