学习记录
初学JavaScript正则表达式(一)
给单个单词is改为大写的IS\bis\b // \b指的是单词边界ISHe is a boy This is a test isn't it给以http://开头并且以jpg结尾的链接删除掉http://// //要分别通过转义字符\转义 第一个.指的是任意字符 第二个点用其本意,需要用转义字符\转义...
2019-08-24 11:58:17
102
                <h1>给单个单词is改为大写的IS</h1> 
\bis\b        //  \b指的是单词边界

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})-/-/$

2-3-$1

1998-05-12
        
1999/06/06
        
1786/05-02
        
125896/03/06
        
2587-06-08

 

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