I get a string from server and it contains <br> and I want to replace it with \n
First I use this method:
let description = user.description.replacingFirstOccurrence(of: "<br>", with: "\n")
But because there is no space before <br> this method isn't working
then I use the same method as this link
Replace <br> in an NSString with a new line
let description = user?.description ?? ""
let filteredDescription = Array(description).reduce("") {$0 + ($1 == "<br>" ? "\n" : $1)}
But I get this error now:
Cannot invoke 'reduce' with an argument list of type '(String, @escaping (String, String) -> String)'
May I ask anyone to help me? Thanks