Email Pattern check in Android

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Created by arifhasnat on 12/20/15.
*/
public class Utility {

private static Pattern pattern;
private static Matcher matcher;
//Email Pattern
private static final String EMAIL_PATTERN = “[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+”;

/**
* Validate Email with regular expression
*
* @param email
* @return true for Valid Email and false for Invalid Email
*/
public static boolean validate(String email) {
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s