Answers for "swift string substring from range"

0

how can i find range of a string in another string swift

let str = "abcde"
if let range = str.range(of: "cd") {
  let substring = str[..<range.lowerBound] // or str[str.startIndex..<range.lowerBound]
  print(substring)  // Prints ab
}
else {
  print("String not present")
}
Posted by: Guest on February-08-2021
0

find range of string swift

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

}
Posted by: Guest on October-20-2020

Code answers related to "swift string substring from range"

Code answers related to "Swift"

Browse Popular Code Answers by Language