Last active
January 27, 2016 19:26
-
-
Save Shehryar/9a41cfa9633ec9b77dcf to your computer and use it in GitHub Desktop.
Returns whether a substring exists in a string
This file contains 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 { | |
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