diff --git a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMConsolidator.swift b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMConsolidator.swift index 2e90306b..6f1f44d8 100644 --- a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMConsolidator.swift +++ b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMConsolidator.swift @@ -145,20 +145,3 @@ extension vChewingLM { } } } - -// MARK: - String Extension - -extension String { - fileprivate mutating func regReplace(pattern: String, replaceWith: String = "") { - // Ref: https://stackoverflow.com/a/40993403/4162914 && https://stackoverflow.com/a/71291137/4162914 - do { - let regex = try NSRegularExpression( - pattern: pattern, options: [.caseInsensitive, .anchorsMatchLines] - ) - let range = NSRange(startIndex..., in: self) - self = regex.stringByReplacingMatches( - in: self, options: [], range: range, withTemplate: replaceWith - ) - } catch { return } - } -} diff --git a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMInstantiator_DateTimeExtension.swift b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMInstantiator_DateTimeExtension.swift index 2b5e5d48..87c62e9d 100644 --- a/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMInstantiator_DateTimeExtension.swift +++ b/Packages/vChewing_LangModelAssembly/Sources/LangModelAssembly/LMInstantiator_DateTimeExtension.swift @@ -77,23 +77,6 @@ extension vChewingLM.LMInstantiator { } } -// MARK: - String Extension - -extension String { - fileprivate mutating func regReplace(pattern: String, replaceWith: String = "") { - // Ref: https://stackoverflow.com/a/40993403/4162914 && https://stackoverflow.com/a/71291137/4162914 - do { - let regex = try NSRegularExpression( - pattern: pattern, options: [.caseInsensitive, .anchorsMatchLines] - ) - let range = NSRange(startIndex..., in: self) - self = regex.stringByReplacingMatches( - in: self, options: [], range: range, withTemplate: replaceWith - ) - } catch { return } - } -} - // MARK: - Date Time Language Conversion Extension private let tableMappingArabicNumeralsToChinese: [String: String] = [ diff --git a/Packages/vChewing_SwiftExtension/Sources/SwiftExtension/SwiftExtension.swift b/Packages/vChewing_SwiftExtension/Sources/SwiftExtension/SwiftExtension.swift index 97edb83a..98843b46 100644 --- a/Packages/vChewing_SwiftExtension/Sources/SwiftExtension/SwiftExtension.swift +++ b/Packages/vChewing_SwiftExtension/Sources/SwiftExtension/SwiftExtension.swift @@ -135,3 +135,20 @@ public struct AppProperty { } } } + +// MARK: - String Extension + +extension String { + public mutating func regReplace(pattern: String, replaceWith: String = "") { + // Ref: https://stackoverflow.com/a/40993403/4162914 && https://stackoverflow.com/a/71291137/4162914 + do { + let regex = try NSRegularExpression( + pattern: pattern, options: [.caseInsensitive, .anchorsMatchLines] + ) + let range = NSRange(startIndex..., in: self) + self = regex.stringByReplacingMatches( + in: self, options: [], range: range, withTemplate: replaceWith + ) + } catch { return } + } +}