I am splitting a string into array at new line. The text comes from a server and can be created on multiple platforms. Have no issues with Unix text, however because of the new line definition issues (\n\r vs \n), the text is not split if it is sent from Windows-based server.
I am using this to find a regex expression for a new line and replace it with \n:
let stringRev = self.string.stringByReplacingOccurrencesOfString( "(\r\n|\r|\n)", withString: "\n", options: NSStringCompareOptions.RegularExpressionSearch, range: nil)
let myArray = stringRev.componentsSeparatedByString("\n")
Is there a way to do it in Swift?
Many thanks!