         }
     }
     
-    func replace(_ pattern: String, replacement: (String) -> String) -> String {
+    func replace(_ pattern: String, replacement: @escaping (String) -> String) -> String {
+#if os(Linux)
+        guard let regex = try? RegularExpression(pattern: pattern, options: []) else { return self }
+#else
         guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else { return self }
+#endif
         let mutableString = NSMutableString(string: self)
         regex.enumerateMatches(in: self, options: [], range: NSMakeRange(0, characters.count)) { result, _, _ in
             guard let result = result else { return }

            let matched = mutableString.substring(with: range)
            mutableString.replaceCharacters(in: range, with: replacement(matched))
        }
        return mutableString as String
    }
}


        case (.full(.number), .half(.number)):
            return string.shift(-Distance.alnum, pattern: "[０-９]")
        case (.half(.katakana), .full(.katakana)):
            return string.replace("\\p{Katakana}") { $0.full }
        case (.full(.katakana), .half(.katakana)):
            return string.replace("\\p{Katakana}") { $0.half }
        default:
            return string
        }
    }
}

