zoukankan      html  css  js  c++  java
  • Swift_String的操作

         //字符串的替换

            let  ReplaceString = "http://www.aimonkeycn"

            let FilterReplace = ReplaceString.replacingOccurrences(of: "", with: ".")

            print(FilterReplace)

            

            //字符串的删除

            let str = ReplaceString.replacingOccurrences(of: "w", with: "")

            print(str)

            

            //字符串的截取

            //ReplaceString 转换为OC 的字符串使用,根据范围来截取字符串

            let subString1 = (ReplaceString as NSString).substring(with: NSMakeRange(1, 3))

            print(subString1)

            

            //截取下标2 之前的字符

            let subString2 = (ReplaceString as NSString).substring(to: 2)

            print(subString2)

            //截取下标2 之后(含有2)

            let subString3 = (ReplaceString as NSString).substring(from: 2)

            print(subString3)

            

            //字符串的分割

            let url  = "http://blog.csdn.net/hello_hwc?viewmode=list"

            let urled = url.components(separatedBy: "/")

            print(urled)

     

           //字符串的拼接

                      let str = "Hello"
                      let newStr = str + "work"
                      print(newStr)        //Hellowork

          

                    let str = String(format: "称呼 : %@", dic["firstName"]! as! CVarArg)  

  • 相关阅读:
    2,ActiveMQ-入门
    1,Java消息服务-JMS
    2,Executor线程池
    Thymeleaf-模板引擎
    1,线程基础
    8,HashMap子类-LinkedHashMap
    7,HashMap
    ncnn编译安装-20190415
    VS2015 C#项目工程配置emgucv依赖的方法
    java jni 调用c++ opencv代码成功范例
  • 原文地址:https://www.cnblogs.com/lcl15/p/6214694.html
Copyright © 2011-2022 走看看