 
 // MARK: -
 
-private extension LineEnding {
+private extension BidirectionalCollection where Element == LineEnding {
     
-    static let regexPattern = "\\r\\n|[\\n\\r\\u0085\\u2028\\u2029]"
+    var regexPattern: String {
+        
+        assert(!self.isEmpty)
+        assert(self.count == self.unique.count)
+        
+        let multiples = self.filter { $0.length > 1 }
+        let singles = self.filter { $0.length == 1 }
+        
+        return (multiples + singles).map(\.string).joined(separator: "|")
+    }
+    
 }
 
 

    /// - Returns: String replacing line ending characers.
    func replacingLineEndings(with lineEnding: LineEnding) -> String {
        
        return self.replacingOccurrences(of: LineEnding.regexPattern, with: lineEnding.string, options: .regularExpression)
    }
    
    

    /// The first line ending type.
    var detectedLineEnding: LineEnding? {
        
        guard let range = self.range(of: LineEnding.allCases.regexPattern, options: .regularExpression) else { return nil }
        
        // -> Swift treats "\r\n" also as a single character.
        let character = self[range.lowerBound]
