Created
December 24, 2017 18:11
-
-
Save dcampogiani/5101541b8415d058d05b56f088bd6113 to your computer and use it in GitHub Desktop.
This file contains 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
val VALID_EMAIL_ADDRESS_REGEX = Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", Pattern.CASE_INSENSITIVE)!! | |
val VALID_PHONE_NUMBER_ADDRESS_REGEX = Pattern.compile("\\d{10}|(?:\\d{3}-){2}\\d{4}|\\(\\d{3}\\)\\d{3}-?\\d{4}", Pattern.CASE_INSENSITIVE)!! | |
fun validMail(input: String): Boolean { | |
val matcher = VALID_EMAIL_ADDRESS_REGEX.matcher(input) | |
return matcher.find() | |
} | |
fun validNumber(input: String): Boolean { | |
val matcher = VALID_PHONE_NUMBER_ADDRESS_REGEX.matcher(input) | |
return matcher.find() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment