Here you can find the source of getSafeMailAddr(String mailAddr)
public static String getSafeMailAddr(String mailAddr)
//package com.java2s; //License from project: Open Source License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String getSafeMailAddr(String mailAddr) { Pattern reg = Pattern.compile("[\\w_]+@[\\w_]+\\.[A-Za-z]{2,4}"); Matcher exec = reg.matcher(mailAddr); if (exec.find()) { return exec.group(0); }//w w w . j a v a 2 s . co m return mailAddr; } }