I'm having a problem when I want to create string from a index of string that contains a special character. I'll post you a playground example.
var str = """
circular para poder realizar sus tareas laborales correspondientes a las actividades de comercialización de alimentos
"""
let regex = try? NSRegularExpression(pattern: ".", options: .caseInsensitive)
let results = regex?.matches(in: str, options: .withoutAnchoringBounds, range: NSRange(0..<str.count - 1))
results?.forEach { result in
let newStr = String(str[Range(result.range, in: str)!])
print(newStr)
}
Now I get an error when the range of the character "ó" wants to form a string. How can I solve this?
Thanks