Check out example codes for "swift replace newlines with space". It will help you in understanding the concepts better.

Code Example 1

let myString = "This \n is a st\tri\rng"
let trimmedString = myString.components(separatedBy: .whitespacesAndNewlines).joined()

Learn ReactJs, React Native from akashmittal.com