<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-JavaScript中用户登录名的正则表达式及解析</title>
</head>
<body>
<div id="main"></div>
<script>
    var pattern = /^[a-zA-Z0-9_-]{4,16}$/;
    w("var pattern = /^[a-zA-Z0-9_-]{4,16}$/;");
    w("pattern.test('ifat3') = "+pattern.test('ifat3'));
    w("pattern.test('42du') = "+pattern.test('42du'));
    w("pattern.test('42du-_') = "+pattern.test('42du-_'));
    w("pattern.test('_42du') = "+pattern.test('_42du'));
    w("pattern.test('42d') = "+pattern.test('42d'));
    w("pattern.test('42du42du42du42du1') = "+pattern.test('42du42du42du42du1'));
    w("pattern.test('42du@') = "+pattern.test('42du@'));
    function w(val) {
        document.getElementById("main").innerHTML += val +"<br />";
    }
</script>
</body>
</html>