<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-密码强度的正则表达式(JavaScript)总结</title>
</head>
<body>
<div id="main"></div>
<script>
    var pattern = /^[\w_-]{6,16}$/;
    w("var pattern = /^[\\w_-]{6,16}$/;");
    w("pattern.test('123456') = "+pattern.test('123456')+";");
    w("pattern.test('-ifat33') = "+pattern.test('-ifat33')+";");
    w("pattern.test('42du') = "+pattern.test('42du')+";");
    w("pattern.test('du42du42du42du421') = "+pattern.test('du42du42du42du421')+";");
    w("pattern.test('42du42@') = "+pattern.test('42du42@')+";");
    function w(val) {
        document.getElementById("main").innerHTML += val +"<br />";
    }
</script>
</body>
</html>