Question: I want to test user input to see if the entire input matches the following regex. How do I do that with Swift?

`[a-zA-Z]+@[a-zA-Z]+.[a-zA-Z]`

Answer: 
Here's a way to do it in Swift *without* `NSRegularExpression`. You still need to `import Foundation`.

```swift
let email = "foo@bar.com"
if let _ = email.range(of: #"[a-zA-Z]+@[a-zA-Z]+.[a-zA-Z]"#,
                                 options: .regularExpression) {
    print("We have a match!")
}

```
I'm using this extension in all of my projects:

```
extension String {
    func matchsIn(regexString: String) -> Bool {
        do { let regex = try NSRegularExpression(pattern: regexString, options: [])
             return regex.firstMatch(in: self, options: [], range: NSMakeRange(0, self.utf8.count)) != nil
        } catch { return false }
    }
}

```