美文网首页
swift 字符串的截取

swift 字符串的截取

作者: 科24 | 来源:发表于2017-06-05 18:38 被阅读10次

let index = str.index(str.startIndex, offsetBy: 9);

//from

let s = str.substring(from: index);

//to

let s1 = str.substring(to: index);

//with

let start = str.index(str.startIndex, offsetBy: 7);

let end = str.index(str.endIndex, offsetBy: -3);

var ran = Range(uncheckedBounds: (start,end));

str.substring(with: ran)

相关文章

网友评论

      本文标题:swift 字符串的截取

      本文链接:https://www.haomeiwen.com/subject/rocwfxtx.html