zoukankan      html  css  js  c++  java
  • 初学JavaScript正则表达式(一)

    给单个单词is改为大写的IS

    is        //  指的是单词边界
    
    IS
    He is a boy
            
    This is a test
            
    isn't it

     

    给以http://开头并且以jpg结尾的链接删除掉http://

    //   //要分别通过转义字符转义    第一个.指的是任意字符   第二个点用其本意,需要用转义字符转义
    
    http://(.+.jpg)    
    
    $1
    http://img.host.com/images/djkahdjas.jpg
            
    https://img.host.com/images/djkahdjas.png
            
    http://img.host.com/images/djkahdjas.png
            
    https://img.host.com/images/djkahdjas.png
            
    http://img.host.com/images/djkahdjas.jpg
            
    https://img.host.com/images/djkahdjas.jpg

     

    将“年(-/)月(-/)日”类型改为“月-日-年”类型

    ^代表起始位置   $代表终止位置   d代表数字   d{4}代表四个数字    [-/]代表-或/   ()代表分组
    第一个()即为$1  第二个()即为$2   以此类推
    
    ^(d{4})[-/](d{2})[-/](d{2})$
    
    $2-$3-$1
    1998-05-12
            
    1999/06/06
            
    1786/05-02
            
    125896/03/06
            
    2587-06-08

    整理自慕课网教学 点此进入

    博主信息:

    昵称:HamyFrank

    网站:我的网站

    邮箱: xueshuai_12@163.com

    QQ:246776020

    QQ群:1063233592

    WeChat:js_cool_100

  • 相关阅读:
    iOS input disabled显示不清楚
    钉钉小程序——JSAPI
    留言板
    友链
    mysql---存储引擎
    union与limit
    spring--setter注入
    spring---生命周期
    sql03-连接查询
    sql01--认识表
  • 原文地址:https://www.cnblogs.com/xue-shuai/p/12000626.html
Copyright © 2011-2022 走看看