Skip to content

Instantly share code, notes, and snippets.

@karambirov
Created May 10, 2023 06:13
Show Gist options
  • Save karambirov/1ef3bbe1fa82febfe950e0fbac12ed77 to your computer and use it in GitHub Desktop.
Save karambirov/1ef3bbe1fa82febfe950e0fbac12ed77 to your computer and use it in GitHub Desktop.
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