Created
May 10, 2023 06:13
-
-
Save karambirov/1ef3bbe1fa82febfe950e0fbac12ed77 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
public func fuzzilyMatches(string: String, separatorsSet: CharacterSet = .whitespacesAndNewlines) -> Bool { | |
let matchComponents = string.lowercased().components(separatedBy: separatorsSet) | |
return lowercased() | |
.components(separatedBy: separatorsSet) | |
.contains { candidate in | |
matchComponents.contains { | |
candidate.contains($0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment