swift 字符串的截取

2017-06-05  本文已影响10人  科24

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)
上一篇 下一篇

猜你喜欢

热点阅读