Is it possible to write a Swift function that replaces only part of an extended grapheme cluster like 👩👩👧👧?
问题 I want to write a function that could be used like this: let 👩👩👧👦 = "👩👩👧👧".replacingFirstOccurrence(of: "👧", with: "👦") Given how odd both this string and Swift's String library are, is this possible in Swift? 回答1: Using the range(of:options:range:locale:) the solution became quite concise: extension String { func replaceFirstOccurrence(of searchString: String, with replacementString: String) -> String { guard let range = self.range(of: searchString, options: .literal) else { return