Created
June 16, 2011 14:53
-
-
Save sachin-handiekar/1029395 to your computer and use it in GitHub Desktop.
Email Validator
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
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class EmailValidator { | |
public boolean isValidEmailAddress(String emailAddress) { | |
String expression = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; | |
CharSequence inputStr = emailAddress; | |
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); | |
Matcher matcher = pattern.matcher(inputStr); | |
return matcher.matches(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple emailValidator method for copy n paste