Created
February 20, 2015 08:10
-
-
Save dsharmaradicle/e48a88fc3d153f5692ae to your computer and use it in GitHub Desktop.
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
Might be this will helpful to remove error: | |
func isMatch(regex: String, options: NSRegularExpressionOptions) -> Bool | |
{ | |
var error: NSError? | |
var exp = NSRegularExpression(pattern: regex, options: options, error: &error) | |
if let error = error { | |
println(error.description) | |
} | |
var matchCount = exp?.numberOfMatchesInString(self, options: nil, range: NSMakeRange(0, self.length)) | |
return matchCount > 0 | |
} | |
func getMatches(regex: String, options: NSRegularExpressionOptions) -> [NSTextCheckingResult] | |
{ | |
var error: NSError? | |
var exp = NSRegularExpression(pattern: regex, options: options, error: &error) | |
if let error = error { | |
println(error.description) | |
} | |
var matches = exp?.matchesInString(self, options: nil, range: NSMakeRange(0, self.length)) | |
return matches as [NSTextCheckingResult] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment