Java tutorial
//package com.java2s; public class Main { /** * Validate email string * @param email is object of String * @return true if valid email otherwise false */ public static boolean isEmail(String email) { String pattern = "^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\\.([a-zA-Z]){2,4}"; return email != null && email.trim().length() > 0 && email.matches(pattern); } }