zoukankan      html  css  js  c++  java
  • 笔记——《正则表达式》

    记录下最近项目中用到的正则嘻嘻

    <!DOCTYPE html>
    <html>
    
    <head>
        <title>正则</title>
    </head>
    
    <body>
        <div style=" 200px;margin: 0 auto">
            <input type="text" name="" id="txt">
            <button id="jiaoyan" onclick="jiaoyanFun()">校验</button>
        </div>
    </body>
    <script type="text/javascript">
    let isPhone, regEmail, quKongGe,isName,isPwd,isZimu;
    isPhone = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/; //手机
    regEmail = /^[A-Za-z0-9u4e00-u9fa5]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/; //邮箱
    isName = /^[A-Za-z0-9u4e00-u9fa5]{4,30}$/;//只能为中文、数字、英文字母(区分大小写), 特殊字符不允许使用;4-30位字符
    isPwd = /^[A-Za-z0-9_-]{6,16}$/;//密码只能为数字、英文字母(区分大小写)、“_”,其他特殊字符不
    // 可以使用;密码为6-16位字符;
    isZimu = /^[a-z]*$/;
    function jiaoyanFun(argument) {
        var txtValue = document.getElementById("txt").value;
        quKongGe = txtValue.replace(/(^s*)|(s*$)/g, "");//去除前后空格
        if(!isPhone.test(quKongGe)){
            alert('手机号格式不正确');
        }
    }
    </script>
    
    </html>
  • 相关阅读:
    yum 下载安装包以及依赖包
    《将博客搬至CSDN》
    Lucene
    Solr
    LVS原理详解(3种工作模式及8种调度算法)
    正向代理与反向代理
    网关,网卡
    NAT地址转换
    Nginx学习总结
    网络_OSI模型_数据包传输
  • 原文地址:https://www.cnblogs.com/yingzi1028/p/8663474.html
Copyright © 2011-2022 走看看