<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-密码强度的正则表达式(JavaScript)总结</title>
</head>
<body>
<div id="main"></div>
<script>
    var pattern = /^.*(?=.{6,16})(?=.*\d)(?=.*[A-Z]{2,})(?=.*[a-z]{2,})(?=.*[!@#$%^&*?\(\)]).*$/;
    w("pattern.test('du42DU!') = "+pattern.test('du42DU!')+";");
    w("pattern.test('duDUd!') = "+pattern.test('duDUd!')+";");
    w("pattern.test('42dud!') = "+pattern.test('42dud!')+";");
    w("pattern.test('42DUD!') = "+pattern.test('42DUD!')+";");
    w("pattern.test('42duDU') = "+pattern.test('42duDU')+";");
    w("pattern.test('42duU(') = "+pattern.test('42duU(')+";");
    w("pattern.test('42dUU!') = "+pattern.test('42dUU!')+";");
    function w(val) {
        document.getElementById("main").innerHTML += val +"<br />";
    }
</script>
</body>
</html>