diff --git a/CHANGELOG.md b/CHANGELOG.md index 89506214d..59b4b78b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S - Renamed `EdgeInsets` typealias to `SFEdgeInsets` to fix namespace conflicts with swiftUI's `EdgeInsets` Type. [#1055](https://github.com/SwifterSwift/SwifterSwift/pull/1055) by [MussaCharles](https://github.com/MussaCharles) - **Font** - Renamed `Font` typealias to `SFFont` to fix namespace conflicts with swiftUI's `Font` Type. [#1055](https://github.com/SwifterSwift/SwifterSwift/pull/1055) by [MussaCharles](https://github.com/MussaCharles) +- **String** + - Reversed the parameters for the `~=` operator in order to not break the default implementation, which causes issues in `switch` statements, for example. [#1113](https://github.com/SwifterSwift/SwifterSwift/issues/1113) by [guykogus](https://github.com/guykogus) ### Deprecated - **String** diff --git a/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift b/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift index a76e5888a..07f50467d 100755 --- a/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift +++ b/Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift @@ -1050,7 +1050,7 @@ public extension String { /// - rhs: Regex pattern to match against. /// - Returns: true if string matches the pattern. static func ~= (lhs: String, rhs: String) -> Bool { - return lhs.range(of: rhs, options: .regularExpression) != nil + return rhs.range(of: lhs, options: .regularExpression) != nil } #endif @@ -1061,9 +1061,9 @@ public extension String { /// - lhs: String to check on regex. /// - rhs: Regex to match against. /// - Returns: `true` if there is at least one match for the regex in the string. - static func ~= (lhs: String, rhs: NSRegularExpression) -> Bool { - let range = NSRange(lhs.startIndex.. Bool { + let range = NSRange(rhs.startIndex..