提问者:小点点

如何在swift3中获取子字符串的范围?[副本]


如何在swick3中获取子串的范围?

 let string  = "Please Click Here"

我需要点击范围


共2个答案

匿名用户

let string = "Please Click Here"
if let range = string.range(of: "Click") {
   print(range)

}

匿名用户

转换为NSString和userrangeOf

let string  = "Please Click Here"
let range = (string as NSString).range(of: "Click", options: .caseInsensitive)
print(range)