<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-邮箱/邮件地址的正则表达式及分析(JavaScript,email,regex)</title>
</head>
<body>
<div id="main"></div>
<script>
    var pattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    w("pattern.test('cn42du@163.com') = "+pattern.test('cn42du@163.com')+";");
    w("pattern.test('ifat3@sina.com.cn') = "+pattern.test('ifat3@sina.com.cn')+";");
    w("pattern.test('ifat3.it@163.com') = "+pattern.test('ifat3.it@163.com')+";");
    w("pattern.test('ifat3_-.@42du.cn') = "+pattern.test('ifat3_-.@42du.cn')+";");
    w("pattern.test('ifat3@42du.online') = "+pattern.test('ifat3@42du.online')+";");
    w("pattern.test('毛三胖@42du.cn') = "+pattern.test('毛三胖@42du.cn')+";");
    function w(val) {
        document.getElementById("main").innerHTML += val +"<br />";
    }
</script>
</body>
</html>