Comment puis-je trouver la gamme d'une chaîne dans une autre chaîne 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")
}
Crazy Chamois