Skip to content

Instantly share code, notes, and snippets.

@jeksys
Created February 5, 2015 20:58
Show Gist options
  • Save jeksys/3ac52021a6f795e87775 to your computer and use it in GitHub Desktop.
Save jeksys/3ac52021a6f795e87775 to your computer and use it in GitHub Desktop.
string.swift
extension String{
var length: Int{
get{
return self.utf16Count
}
}
func isValidEmail() -> Bool {
let emailRegex = NSRegularExpression(pattern: "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$", options: .CaseInsensitive, error: nil)
return emailRegex?.firstMatchInString(self, options: nil, range: NSMakeRange(0, countElements(self))) != nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment