is Email Address - Java java.util.regex

Java examples for java.util.regex:Match Email

Description

is Email Address

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String str = "java2s.com";
        System.out.println(isEmailAddress(str));
    }//from w w w  . j  a  va 2  s.  c  o m

    public static Boolean isEmailAddress(String str) {
        return str
                .matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
    }
}

Related Tutorials