Skip to content

Instantly share code, notes, and snippets.

@Shehryar
Last active January 27, 2016 19:26
Show Gist options
  • Save Shehryar/9a41cfa9633ec9b77dcf to your computer and use it in GitHub Desktop.
Save Shehryar/9a41cfa9633ec9b77dcf to your computer and use it in GitHub Desktop.
Returns whether a substring exists in a string
extension String {
subscript(pattern: String) -> Bool {
get {
let range = self.rangeOfString(pattern)
return !range.isEmpty
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment