Java regex email

后端 未结 20 2436
清歌不尽
清歌不尽 2020-11-22 13:09

First of all, I know that using regex for email is not recommended but I gotta test this out.

I have this regex:

\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]         


        
20条回答
  •  醉梦人生
    2020-11-22 13:38

    You can checking if emails is valid or no by using this libreries, and of course you can add array for this folowing project.

    import org.apache.commons.validator.routines.EmailValidator;
    
    public class Email{
        public static void main(String[] args){
            EmailValidator email = EmailVlidator.getInstance();
            boolean val = email.isValid("george.parcks@gmail.com");
            System.out.println("Mail is: "+val);
            val = email.isValid("hans.riguer.hotmsil.com");
            System.out.print("Mail is: "+val");
        }
    }
    

    output :

    Mail is: true

    Mail is : false

提交回复
热议问题