Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isEmailLegal(String email) { if (TextUtils.isEmpty(email)) return false; final String REGEXP = "^([a-z0-9\\-_.+]+)@([a-z0-9\\-]+[.][a-z0-9\\-.]+)$"; Pattern p = Pattern.compile(REGEXP); Matcher m = p.matcher(email.toLowerCase()); return m.matches(); } public static boolean matches(String content, String format) { Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(content); boolean matches = matcher.matches(); return matches; } }