参考function test_email(strEmail) { 
  var myReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/; 
  if(myReg.test(strEmail)) return true; 
  return false; 
 }

解决方案 »

  1.   

    Struts有个例子叫Validate的,里面就用到了正则表达式对email作校验的。
    楼主可以参考一下
      

  2.   

    太复杂了,看看rfc821就知道了。
    地址里面可能有路由,甚至可能有地址组,还有注释。
    不是正则表达式能解决的问题,必须语法分析。如果用java,那就javax.mail凑合一下了。
      

  3.   

    import java.util.regex.*;
    public class TestRegex{
    public static void main(String agrs[]){
    String  input ="[email protected]";
    Pattern p = Pattern.compile("^[\\w-.]+@([\\w-]+.)+[\\w-]{2,4}$");
    Matcher m = p.matcher(input);
    boolean b = m.matches();
    System.out.println(b);
    }
    }
      

  4.   

    to Leemaasn:
        我在java里面用,刚开始我也想用那个例子来改,但是我发现里面还有一些关于ip校验的.改起来也比较麻烦.就放弃了
      

  5.   

    你可以看看doc 下面的文档,讲的很清楚了。:
    A typical invocation sequence is thus  Pattern p = Pattern.compile("a*b");
     Matcher m = p.matcher("aaaaab");
     boolean b = m.matches();A matches method is defined by this class as a convenience for when a regular expression is used just once. This method compiles an expression and matches an input sequence against it in a single invocation. The statement  boolean b = Pattern.matches("a*b", "aaaaab");is equivalent to the three statements above, though for repeated matches it is less efficient since it does not allow the compiled pattern to be reused. ....