Create regular expression for validating Email - Android java.util.regex

Android examples for java.util.regex:Email Pattern

Description

Create regular expression for validating Email

Demo Code

import android.text.TextUtils;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isEmail(String email) {
        String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(email);
        return matcher.matches();
    }/*  www  .j  a v a2s .  co m*/

}

Related Tutorials