Providing Swift 3.0 @hallski version here:
self.content = self.content.components(separatedBy: CharacterSet.newlines).joined(separator: " ")
Providing Swift 3.0 @Kjuly version here (note that it replaces any number of newlines with only one \ n. I would rather not use a regular express if someone could tell me the best way):
self.content = self.content.replacingOccurrences(of: "[\r\\n]+", with: "\n", options: .regularExpression, range: Range(uncheckedBounds: (lower: self.content.startIndex, upper: self.content.endIndex)));
Michael Shang Nov 05 '16 at 22:06 2016-11-05 22:06
source share