Skip to content

Instantly share code, notes, and snippets.

@klundberg
Created October 7, 2015 22:27
Show Gist options
  • Save klundberg/b0fcb8bc99151ea28012 to your computer and use it in GitHub Desktop.
Save klundberg/b0fcb8bc99151ea28012 to your computer and use it in GitHub Desktop.
let regex = try NSRegularExpression(pattern: mypattern, options: [])
let str = "some string to match"
if let result = regex.firstMatchInString(str, options: [], range: NSMakeRange(0, str.characters.count)) {
print((str as NSString).substringWithRange((result?.rangeAtIndex(1))!))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment