Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get range of substring in swift3? [duplicate]

Tags:

xcode

ios

swift3

How to get range of substring in swift3?

 let string  = "Please Click Here"

I need range of click

like image 536
samad5353 Avatar asked Oct 30 '16 10:10

samad5353


Video Answer


2 Answers

Convert to NSString and user rangeOf:

let string  = "Please Click Here"
let range = (string as NSString).range(of: "Click", options: .caseInsensitive)
print(range)
like image 150
Hossam Ghareeb Avatar answered Oct 24 '22 02:10

Hossam Ghareeb


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

}
like image 32
Bassam Avatar answered Oct 24 '22 02:10

Bassam