is String an Email using Regex - Android java.util.regex

Android examples for java.util.regex:Email Pattern

Description

is String an Email using Regex

Demo Code


//package com.java2s;

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

public class Main {

    public static boolean isEmail(String email) {
        String str = "^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);
        return m.matches();

    }//from w  ww .ja va 2  s  . c  o  m
}

Related Tutorials