Introduce 'splitByNewline' string extension

This commit is contained in:
Danny Moesch 2020-01-18 22:30:38 +01:00 committed by Mingshen Sun
parent 2ffc9ba568
commit 56b2205376
3 changed files with 9 additions and 9 deletions

View file

@ -17,6 +17,10 @@ extension String {
allowed.insert(charactersIn: unreserved)
return addingPercentEncoding(withAllowedCharacters: allowed)
}
public func splitByNewline() -> [String] {
return split(omittingEmptySubsequences: false) { $0 == "\n" || $0 == "\r\n" }.map(String.init)
}
}
extension String {