package com.css.common.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 判断EMAIL文件的格式
*
* @version 1.0
*
*/
public class ValidateUtil {
/**
* 验证Email
* @param line EMAIL地址
* @return 错误返回空字符串,正确返回Email地址
*/
public static String parseEmail(String line) {
Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
Matcher m = p.matcher(line);
StringBuffer buf = new StringBuffer();
while (m.find()) {
buf.append(m.group());
}
return buf.toString();
}
/**
* 验证Email
* @param line EMAIL地址
* @return 错误返回false,正确返回true
*/
public static boolean validateEmail(String line) {
Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
Matcher m = p.matcher(line);
if (m.find()) {
return true;
} else {
return false;
}
}
public static void main(String[] args){
String go = ValidateUtil.parseEmail("zhangzenglun@13363...com");
System.out.println(go);
}
}