Created
February 21, 2015 02:06
-
-
Save claymcleod/39214f470d71363d6410 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Title: Regular Expressions with Swift | |
// Authors: Clay McLeod | |
// Description: A brief overview of regular expressions with Swift | |
// Section: Swift | |
// Subsection: General | |
import Foundation | |
var error: NSError? | |
let pattern = "[A-Za-z]atch" | |
let testingString = "Hatch" | |
let expression = NSRegularExpression(pattern: pattern, options: .CaseInsensitive, error: &error) | |
if let match = expression?.matchesInString(testingString, options: nil, range: NSMakeRange(0, countElements(testingString))) { | |
println("Testing string matched the regular expression!"); | |
} else { | |
println("Match not found.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment