Skip to content

Instantly share code, notes, and snippets.

@oisdk
Last active Feb 3, 2018
Embed
What would you like to do?
#if os(Linux)
import Glibc
#else
import Darwin
#endif
extension String {
func contains(s: String, caseSensitive: Bool = true) -> Bool {
if !caseSensitive { return lowercaseString.contains(s.lowercaseString) }
return characters
.indices
.lazy
.map(characters.suffixFrom)
.contains { tail in tail.startsWith(s.characters) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment