• swift 取出中间文本


        func  stringmid (wholestring:String,front:String,behind:String)->String

        {

     

            

            

            if wholestring.isEmpty

            {

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

                

            }else  {

                var whole:NSString=wholestring

                

                

                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(whole as String)

                        

                    } else {return("")} //没有找到behindwholestring

                   

                    

                } else  {return("")}  // 没有找到front wholestring

                

               

            }

            

     

        }

  • 相关阅读:
    lucene入门
    ssm框架整合
    springmvc异常处理器和拦截器
    软件测试的策略是什么?
    软件质量保证体系是什么 国家标准中与质量保证管理相关的几个标准是什么?他们的编号和全称是什么?
    • β测试
    • α测试
    • 白盒测试
    黑盒测试
    • 数据库的兼容性
  • 原文地址:https://www.cnblogs.com/youyaoqi/p/5486647.html
Copyright © 2020-2023  润新知