正则表达式匹配大写,小写,数字及特殊字符

前端之家收集整理的这篇文章主要介绍了正则表达式匹配大写,小写,数字及特殊字符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function test() {
            var regular1 = /^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[a-z])[0-9A-Za-z!-)]{8,}$/;
            var regular2 = /((?=[\x21-\x7e]+)[^A-Za-z0-9])/;
            var username = "#ABcd1234";
            if (regular1.test(username) && regular2.test(username)) {
                alert("yes");
            } else {
                alert("no");
            }
        }
    </script>
</head>
<body>
    <input type="button" value="click" onclick="test()"/>
</body>
</html>
原文链接:https://www.f2er.com/regex/360368.html

猜你在找的正则表达式相关文章