String emailRegex = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; Pattern pat = Pattern.compile(emailRegex); Boolean matchFlag = pat.matcher("aabcc-gedt@163.com").find(); if (matchFlag) { System.out.println("match"); } else { System.out.println("do not match"); } //简写 if (Pattern.compile(emailRegex).matcher("aabcc-gedt@163.com").find()) { System.out.println("match"); } else { System.out.println("do not match"); }
原文:http://www.cnblogs.com/aaronhoo/p/5239917.html