Created
March 15, 2020 16:00
-
-
Save foxicode/2d8e8f00be79aac861c64a619aaa7372 to your computer and use it in GitHub Desktop.
Revisions
-
foxicode created this gist
Mar 15, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ extension String { func matches(_ expression: String) -> Bool { if let range = range(of: expression, options: .regularExpression, range: nil, locale: nil) { return range.lowerBound == startIndex && range.upperBound == endIndex } else { return false } } var isValidEmail: Bool { matches("[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}") } }