字符串截取
-
三种截取方法
let str:String = "天行健,君子以自强不强;地势坤,君子以厚德载物。" let start = str.startIndex.advancedBy(2) let stop = str.endIndex.advancedBy(-2) let strSub1 = str.substringFromIndex(start) let strSub11 = str.substringFromIndex('天行健,'.endIndex) //"天行健,"改字符仅仅为占位符,可以用任何相同长度字符串代替 let strSub2 = str.substringToIndex(stop) let strSub = str.substringWithRange(start..<stop)
网友评论