zoukankan      html  css  js  c++  java
  • 校验 url 是否以http 或者https 开头

    1. var reUrl01 = /^((ht|f)tps?)://([w-]+(.[w-]+)*/?)+(?([w-.,@?^=%&:/~+#]*)+)?$/;

    1. var reUrl01 = /^((ht|f)tps?)://([w-]+(.[w-]+)*/?)+(?([w-.,@?^=%&:/~+#]*)+)?$/;

    2. //(1)、直接匹配域名地址:

    3. var matchString1 = 'https://www.jsdaxue.com';

    4. console.log(reUrl01.test(matchString1)); // ==> true

    5. var matchString2 = 'https://www.jsdaxue.com/';

    6. console.log(reUrl01.test(matchString2)); // ==> true

    7. var matchString3 = 'https://www.jsdaxue.com//'; // ==> 不允许非域名或参数以外的地方出现双“/”;

    8. console.log(reUrl01.test(matchString3)); // ==> false

    9. //(2)、匹配链接含(*.htm,*.html,*.php,*.aspx...)后缀的地址:

    10. var matchString4 = 'https://www.jsdaxue.com/EditPosts.aspx';

    11. console.log(reUrl01.test(matchString4)); // ==> true

    12. var matchString5 = 'https://www.jsdaxue.com./EditPosts.aspx'; // ==> 不允许参数以外的地方以双“.”结尾;

    13. console.log(reUrl01.test(matchString5)); // ==> false

    转载 http://www.jsdaxue.com/archives/183.html

  • 相关阅读:
    activiti并行和串行区别
    SpringMVC 封装返回结果对象
    maven基础
    activiti表
    SpringBoot进阶
    SpringBoot基础
    javascript ES6模块化
    Vuejs搜索下拉框
    Vuejs2.0 + bootstrap demo
    maven settings.xml
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/12049648.html
Copyright © 2011-2022 走看看