正则表达式常用语法速查+一个简单使用案例

文章目录

    • 一、常用元字符(注意区分大小写,大写是相反的意思)
    • 二、重复量词与贪婪非贪婪模式
    • 三、自定义字符集合与字符边界问题
      • 自定义字符集合
      • 字符边界问题(匹配的不是字符而是位置,符合某种条件的位置)
    • 四、选择符和分组以及反向引用
      • 选择符和分组
      • 反向引用
    • 五、零宽断言
    • 六、小案例练习
      • 获取网页中所有超链接
        • - 示例网页源码:
        • - 正则表达式
        • -加一个零宽断言
    • 附:常用字符



一、常用元字符(注意区分大小写,大写是相反的意思)

\d 任意一个数字 0-9的任意一个
\w 任意一个字母或数字或下划线,也就是a-z A-Z 0-9 _任意一个
\s 包括空格 制表符 换行符等空白字符的其中任意一个
. 小数点可以匹配任意一个字符(除了换行符)。如果要匹配包括\n在内的所有字符,一般用[\s\S]


二、重复量词与贪婪非贪婪模式

{n} 表达式重复n次
{m,n}表达式至少重复m次,最多重复n次
{m,}表达式至少重复m次
? 匹配表达式0次或者1次数,相当于{0,1}
+ 表达式至少出现1次 相当于{1,}
* 表达式不出现或出现人一次,相当于{0,}

贪婪模式:匹配字符越多越好,是默认的

非贪婪模式:匹配字符越少越好,修饰匹配次数的特殊符号后再加上一个?号



三、自定义字符集合与字符边界问题

自定义字符集合

[ab5@] 匹配a或b或5或@
[^abc] 匹配abc之外的任意一个字符
[f-k] 匹配f~k之间的任意一个字符
[^A-F0-3] 	匹配A~F 0~3之外的任意一个字符

字符边界问题(匹配的不是字符而是位置,符合某种条件的位置)

^ 与字符串开始的地方匹配
$ 与字符串结束的地方匹配
\b 匹配一个单词边界
-\b匹配这样一个位置:前面的字符和后面的字符不全是\w


四、选择符和分组以及反向引用

选择符和分组

|【分支结构】 左右两边表达式之间或关系,匹配左边或右边
() 【捕获组】 在被修饰匹配次数的时候,括号中的表达式可以作为整体被修饰
			取匹配结果的时候,括号中的表达式匹配到的内容可以被单独得到
			每一对括号会分配一个编号,使用()的捕获根据左括号的顺序从1开始自动编号,捕获元素编号为0的第一个捕获是由整个正则表达式模式匹配的文本
(?:Expression) 一些表达式中,不得不使用() 但又不需要保存()中子表达式匹配的内容,这时可以用非捕获组来抵消使用()带来的副作用

反向引用

每一对()会分配一个编号,使用()的捕获根据左括号的顺序从1开始自动编号
通过反向引用,可以对分组已捕获的字符串进行引用


五、零宽断言

(?=exp) 断言自身出现的位置的后面能匹配表达式exp 
(?<=exp) 断言自身出现的位置的前面能匹配表达式exp
(?!exp) 断言此位置的后面不能匹配表达式exp
(?


六、小案例练习

获取网页中所有超链接

- 示例网页源码:

<html>
<head>
<meta name="viewport" content="width=device-width,user-scalable=0,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>重庆城市管理职业学院title>

<link type="text/css" href="/_css/_system/system.css" rel="stylesheet"/>
<link type="text/css" href="/_upload/site/1/style/1/1.css" rel="stylesheet"/>
<link type="text/css" href="/_upload/site/00/03/3/style/4/4.css" rel="stylesheet"/>
       <LINK href="/_css/tpl2/system.css" type="text/css" rel="stylesheet"> 
       <LINK href="/_css/tpl2/default/default.css" type="text/css" rel="stylesheet"> 
<link type="text/css" href="/_js/_portletPlugs/simpleNews/css/simplenews.css" rel="stylesheet" />
<link type="text/css" href="/_js/_portletPlugs/datepicker/css/datepicker.css" rel="stylesheet" />
<link type="text/css" href="/_js/_portletPlugs/sudyNavi/css/sudyNav.css" rel="stylesheet" />

<script language="javascript" src="/_js/jquery.min.js" sudy-wp-context="" sudy-wp-siteId="3">script>
<script language="javascript" src="/_js/jquery.sudy.wp.visitcount.js">script>
<script type="text/javascript" src="/_js/_portletPlugs/datepicker/js/jquery.datepicker.js">script>
<script type="text/javascript" src="/_js/_portletPlugs/datepicker/js/datepicker_lang_HK.js">script>
<script type="text/javascript" src="/_js/_portletPlugs/sudyNavi/jquery.sudyNav.js">script>
<link rel="stylesheet" href="/_upload/tpl/00/03/3/template3/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="/_upload/tpl/00/03/3/template3/extends/extends.css" type="text/css" media="all" />
<link href="/_upload/tpl/00/03/3/template3/css/media.css" rel="stylesheet">
<script type="text/javascript" src="/_upload/tpl/00/03/3/template3/js/sudy.js">
script>
<script type="text/javascript" src="/_upload/tpl/00/03/3/template3/extends/extends.js">
script>
<script type="text/javascript">
$(function(){
	var test = window.location.host;

if (test == "www.cswu.cn"){
	$(".foot-r").addClass("foot-bq")
	}else{
	$(".foot-r").removeClass("foot-bq")
	}
	})
script>
<script type="text/javascript">
$(function(){
	$(".scroll").sudyScroll({
 		width: 350,		// 单元格宽度
		height: 85,		// 单元格高度
		display: 3,		// 显示几个单元
		step: 3,			// 每次交替增加几个单元,值不能大于display
		dir:"y",		// 交替方向,纵向为"y",水平为"x",默认为"y"纵向交替
		auto:true,		// 是否自动交替,默认为自动
		speed:500,		// 交替速度
		hoverPause:5000,		// 交替暂留时间
		navigation:false,		// 是否显示导航按钮
		navTrigger:"click", 	// 导航按钮事件
		pagination:true,		// 是否显示索引按钮
		pagTrigger:"mouseenter"  //索引按钮事件
	});
});
script>
head>


<body>
<link custom="self"  href="/_upload/tpl/00/03/3/template3/css/media.css" rel="stylesheet">



<div class="wrapper main_head" id="header">
    <div class="top">
        <div class="inner clearfix">
            <div class="top_l" frag="面板20">
                <div frag="窗口20">
                    <div id="wp_nav_w20"> 

 
<ul class="wp_nav" data-nav-config="{drop_v: 'down', drop_w: 'right', dir: 'y', opacity_main: '-1', opacity_sub: '-1', dWidth: '0'}">
      
     <li class="nav-item i1 "> 
         <a href="/57/list.htm" title="学生" target="_self"><span class="item-name">学生span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i2 "> 
         <a href="/58/list.htm" title="教工" target="_self"><span class="item-name">教工span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i3 "> 
         <a href="/60/list.htm" title="考生" target="_self"><span class="item-name">考生span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i4 "> 
         <a href="/59/list.htm" title="校友" target="_self"><span class="item-name">校友span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i5 "> 
         <a href="/61/list.htm" title="访客" target="_self"><span class="item-name">访客span>a><i class="mark">i> 
          
     li> 
      
ul> 
 
 
 div>
                div>
            div>
            <div class="top_r" frag="面板24">
                <div frag="窗口24">
                    <div id="wp_nav_w24"> 

 
<ul class="wp_nav" data-nav-config="{drop_v: 'down', drop_w: 'right', dir: 'y', opacity_main: '-1', opacity_sub: '-1', dWidth: '0'}">
      
     <li class="nav-item i1 "> 
         <a href="http://www.cswu.cn/english/main.htm" title="English" target="_blank"><span class="item-name">Englishspan>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i2 "> 
         <a href="http://eip.cswu.cn/EIP/nonlogin/user/index.htm" title="一站式服务大厅" target="_blank"><span class="item-name">一站式服务大厅span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i3 "> 
         <a href="http://ky.cswu.cn:8083" title="校园VR导视" target="_blank"><span class="item-name">校园VR导视span>a><i class="mark">i> 
          
     li> 
      
ul> 
 
 
 div>
                div>
            div>
        div>
    div>
    <div class="inner">
        
  	
        <div class="head clearfix" frag="面板1">
            <div class="logo" frag="窗口1" portletmode="simpleSiteAttri">
                  	<a class="site-url" href="/main.htm"><img src="/_upload/tpl/00/03/3/template3/images/logo.png" width="329" height="65"/>a>
            div>
            <div class="search_box" frag="窗口29">
                  	
                <form method="POST" action="/_web/search/doSearch.do?locale=zh_CN&request_locale=zh_CN&_p=YXM9MyZ0PTMmZD03JnA9MSZtPVNTJmM9dzI5JnY9QyY_" target="_blank" onsubmit="if ($('#keyword').val() === '请输入关键字') { $('#keyword').val(''); }">
    <div class="wp_search">
        <table>
            <tr>
                <td height="25px">
                    <input id="keyword" name="keyword" style="width: 150px" class="keyword" type="text" value="请输入关键字" onfocus="if (this.value === '请输入关键字') { this.value = ''; }"
                           onblur="if (this.value === '') { this.value = '请输入关键字'; }" />
                td>
                <td>
                    <input name="btnsearch" class="search" type="submit" value=""/>
                td>
            tr>
        table>
    div>
form>
            div>
        div>
        <div class="navbar" frag="面板2">
            <div class="navbox" frag="窗口2">
                  	
                <div id="wp_nav_w2"> 

 
<ul class="wp_nav" data-nav-config="{drop_v: 'down', drop_w: 'right', dir: 'y', opacity_main: '1', opacity_sub: '0.8', dWidth: '0'}">
      
     <li class="nav-item i1 "> 
         <a href="/main.htm" title="学校首页" target="_self"><span class="item-name">学校首页span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i2 "> 
         <a href="/25/list.htm" title="学校概况" target="_self"><span class="item-name">学校概况span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i2-1 "> 
                 <a href="/66/list.htm" title="学校简介" target="_self"><span class="item-name">学校简介span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i2-2 "> 
                 <a href="/67/list.htm" title="现任领导" target="_self"><span class="item-name">现任领导span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i2-3 "> 
                 <a href="http://www.cswu.cn/2016/0517/c68a5998/page.htm" title="学校标志" target="_self"><span class="item-name">学校标志span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i2-4 "> 
                 <a href="/69/list.htm" title="办学成果" target="_self"><span class="item-name">办学成果span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i2-5 "> 
                 <a href="http://ky.cswu.cn:8083" title="校园导视" target="_blank"><span class="item-name">校园导视span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i3 "> 
         <a href="/26/list.htm" title="机构设置" target="_self"><span class="item-name">机构设置span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i4 "> 
         <a href="/44/list.htm" title="人才培养" target="_self"><span class="item-name">人才培养span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i4-1 "> 
                 <a href="http://www.cswu.cn/jwc/" title="高职教育" target="_blank"><span class="item-name">高职教育span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i4-2 "> 
                 <a href="http://www.cswu.cn/jxjyxy" title="继续教育" target="_blank"><span class="item-name">继续教育span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i5 "> 
         <a href="http://www.cswu.cn/kjc/" title="科学研究" target="_blank"><span class="item-name">科学研究span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i6 "> 
         <a href="/28/list.htm" title="招生就业" target="_self"><span class="item-name">招生就业span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i6-1 "> 
                 <a href="http://zs.cswu.cn/" title="招生工作" target="_blank"><span class="item-name">招生工作span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i6-2 "> 
                 <a href="http://www.cswu.cn/jyzdzx/" title="就业工作" target="_blank"><span class="item-name">就业工作span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i7 "> 
         <a href="/32/list.htm" title="合作交流" target="_blank"><span class="item-name">合作交流span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i7-1 "> 
                 <a href="http://www.cswu.cn/cjrhzx/" title="产教融合中心" target="_blank"><span class="item-name">产教融合中心span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i8 "> 
         <a href="/45/list.htm" title="文化生活" target="_self"><span class="item-name">文化生活span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i8-1 "> 
                 <a href="http://www.cswu.cn/xsc/" title="青春学工" target="_blank"><span class="item-name">青春学工span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i8-2 "> 
                 <a href="/38/list.htm" title="讲座信息" target="_self"><span class="item-name">讲座信息span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i8-3 "> 
                 <a href="/xyfg/list.htm" title="校园风光" target="_self"><span class="item-name">校园风光span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i9 "> 
         <a href="/46/list.htm" title="校园服务" target="_self"><span class="item-name">校园服务span>a><i class="mark">i> 
          
         <ul class="sub-nav"> 
              
             <li class="nav-item i9-1 "> 
                 <a href="/275/list.htm" title="学校校历" target="_self"><span class="item-name">学校校历span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i9-2 "> 
                 <a href="http://tsgapp.cswu.cn" title="图情服务" target="_blank"><span class="item-name">图情服务span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i9-3 "> 
                 <a href="ftp://ftp.cqcmc.cn/" title="软件下载" target="_blank"><span class="item-name">软件下载span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i9-4 "> 
                 <a href="http://hygl.cswu.cn:8080/" title="会议管理" target="_blank"><span class="item-name">会议管理span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i9-5 "> 
                 <a href="/280/list.htm" title="电话查询" target="_self"><span class="item-name">电话查询span>a><i class="mark">i> 
                  
             li> 
              
             <li class="nav-item i9-6 "> 
                 <a href="http://dzb.cswu.cn/dzb/yd/index.asp" title="邮递查询" target="_blank"><span class="item-name">邮递查询span>a><i class="mark">i> 
                  
             li> 
              
         ul> 
          
     li> 
      
     <li class="nav-item i10 "> 
         <a href="/47/list.htm" title="办事流程" target="_self"><span class="item-name">办事流程span>a><i class="mark">i> 
          
     li> 
      
ul> 
 
 
 div>
            div>
        div>
    div>
div>
<div class="banner" frag="面板28">
    <div class="inner" frag="窗口28">
          	
                        
<script language="JavaScript" class="" >
    var w28imgJsons = [
    
        
            {
            "src": "/_upload/article/images/1a/e4/248f8d6c429b92d9a7198fbd2f1f/c60f4c99-88ed-47a2-8ce5-75e2207ce4d1.jpg",
            "original": "/_upload/article/images/1a/e4/248f8d6c429b92d9a7198fbd2f1f/c60f4c99-88ed-47a2-8ce5-75e2207ce4d1.jpg",
            "title": "欢迎新同学",
            "url": "http://yxw.cswu.cn"
            },
        
    
        
            {
            "src": "/_upload/article/images/bd/02/28f1a03b44d2b2eafe135c915013/8947c2b1-5c3d-4c68-8221-8cf4e72d5ec5.jpg",
            "original": "/_upload/article/images/bd/02/28f1a03b44d2b2eafe135c915013/8947c2b1-5c3d-4c68-8221-8cf4e72d5ec5.jpg",
            "title": "社会主义核心价值观",
            "url": "/2017/0830/c65a26194/page.htm"
            },
        
    
        
            {
            "src": "/_upload/article/images/51/ff/05a45b21416596a9a093d09412d4/0f3150a3-3910-4ba0-a3c2-8d0a7922e8f7.jpg",
            "original": "/_upload/article/images/51/ff/05a45b21416596a9a093d09412d4/0f3150a3-3910-4ba0-a3c2-8d0a7922e8f7.jpg",
            "title": "垃圾分类 从我做起",
            "url": "/2020/0817/c65a44805/page.htm"
            },
        
    
        
            {
            "src": "/_upload/article/images/43/49/7411069e48d6ae5e963272fc1bf2/0034cfe4-62f4-4d31-a98d-d0f471338fa4.png",
            "original": "/_upload/article/images/43/49/7411069e48d6ae5e963272fc1bf2/0034cfe4-62f4-4d31-a98d-d0f471338fa4.png",
            "title": "创建全国文明校园 提升办学治校水平 ",
            "url": "/2020/0817/c65a44804/page.htm"
            },
        
    
        
            {
            "src": "/_upload/article/images/81/80/0b54acce4eae816e890a30d56567/638faa32-04d2-418e-a74b-b7ccf7ab0655.jpg",
            "original": "/_upload/article/images/81/80/0b54acce4eae816e890a30d56567/638faa32-04d2-418e-a74b-b7ccf7ab0655.jpg",
            "title": "吃得文明倡议行动",
            "url": "/2020/0511/c65a42775/page.htm"
            },
        
    
        
            {
            "src": "/_upload/article/images/21/84/d09d2ac64580bfcc5233942c0113/d06e23ab-dd8e-4798-aab1-e004e31b3561.jpeg",
            "original": "/_upload/article/images/21/84/d09d2ac64580bfcc5233942c0113/d06e23ab-dd8e-4798-aab1-e004e31b3561.jpeg",
            "title": "坚定信念 众志成城 打赢疫情防控阻击战",
            "url": "/2020/0205/c65a41663/page.htm"
            }
        
    
    ];
script>

            
        <div class="slider">div>
    div>
div>
<div class="wrapper contain_bg" id="container">
    <div class="inner" frag="面板43">
        <div class="post post-43 mbox" frag="窗口43">
            <div class="tt">
                  	
                <h3 class="tit">
                    <span class="title" frag="标题" title="综合新闻">   综合新闻span>
                h3>
                <div class="more_btn">
                    <span class="more_text"><a href="/34/list.htm">更多a>span>
                div>
            div>
            <div class="con">
                <div id="wp_news_w43"> 

                    <ul class="news_list clearfix">
                        
                        <li class="news news_li n1 clearfix">
                            <div class="news_img">
                                <a href='/2020/0911/c33a45028/page.htm' target='_blank' title='我校举办庆祝第36个教师节系列活动'><img src='/_upload/article/images/25/45/e5ab1fe042faa62a3dcd9b38bee7/c50a6ac3-cac2-47be-a00b-c5a9521cc2d5_s.jpg' width='320' />a>
                            div>
                            <div class="news_con">
                                <div class="news_title">
                                    <a href='/2020/0911/c33a45028/page.htm' target='_blank' title='我校举办庆祝第36个教师节系列活动'>我校举办庆祝第36个教师节系列活动a>
                                div>
                                <div class="news_time">
                                    2020-09-11
                                div>
                            div>
                        li>
                        <li class="news news_li n2 clearfix">
                            <div class="news_img">
                                <a href='/2020/0630/c33a44285/page.htm' target='_blank' title='我校召开干部大会宣布学校行政主要领导任免决定'><img src='/_upload/article/images/11/73/50fb490f427497a78bb6043c1460/7b8606ed-df8a-400e-9700-7dcc4354cded_s.jpg' width='320' />a>
                            div>
                            <div class="news_con">
                                <div class="news_title">
                                    <a href='/2020/0630/c33a44285/page.htm' target='_blank' title='我校召开干部大会宣布学校行政主要领导任免决定'>我校召开干部大会宣布学校行政主要领导任免决定a>
                                div>
                                <div class="news_time">
                                    2020-06-30
                                div>
                            div>
                        li>
                        <li class="news news_li n3 clearfix">
                            <div class="news_img">
                                <a href='/2020/0701/c33a44316/page.htm' target='_blank' title='我校举行庆祝中国共产党成立99周年暨“七一”表彰大会'><img src='/_upload/article/images/c6/e6/6e67421a44aeac59340d7ce04972/22a143ae-e0b1-4a91-9a9f-1a3da936720d_s.jpg' width='320' />a>
                            div>
                            <div class="news_con">
                                <div class="news_title">
                                    <a href='/2020/0701/c33a44316/page.htm' target='_blank' title='我校举行庆祝中国共产党成立99周年暨“七一”表彰大会'>我校举行庆祝中国共产党成立99周年暨“七一”表彰大会a>
                                div>
                                <div class="news_time">
                                    2020-06-30
                                div>
                            div>
                        li>
                        <li class="news news_li n4 clearfix">
                            <div class="news_img">
                                <a href='/2020/0516/c33a42868/page.htm' target='_blank' title='成渝地区双城经济圈商贸流通职业教育集团在成渝两地成立'><img src='/_upload/article/images/52/19/954219614f07b7839b921a6e0e53/67b6194d-eed9-40c4-92c9-25fdfad0cd32_s.jpg' width='320' />a>
                            div>
                            <div class="news_con">
                                <div class="news_title">
                                    <a href='/2020/0516/c33a42868/page.htm' target='_blank' title='成渝地区双城经济圈商贸流通职业教育集团在成渝两地成立'>成渝地区双城经济圈商贸流通职业教育集团在成渝两地成立a>
                                div>
                                <div class="news_time">
                                    2020-05-16
                                div>
                            div>
                        li>
                    ul>
                div> 

            div>
        div>
        <div class="post post-53 mbox" frag="窗口53">
            <div class="con">
                <div id="wp_news_w53"> 
                    <ul class="news_list clearfix">
                        
                        <li class="news n1 clearfix">
                            <span class="news_title"><a href='/2020/1010/c34a45512/page.htm' target='_blank' title='我校扶贫工作小组深入云阳县泥溪镇枞林村推进对口帮扶工作'>我校扶贫工作小组深入云阳县泥溪镇枞林村推进对口帮扶工作a>span><span class="news_meta post_time">2020-10-10span>
                        li>
                        <li class="news n2 clearfix">
                            <span class="news_title"><a href='/2020/1009/c34a45494/page.htm' target='_blank' title='我校召开“巴渝工匠”第十三届高职院校技能竞赛货运代理赛项说明会'>我校召开“巴渝工匠”第十三届高职院校技能竞赛货运代理赛项说明会a>span><span class="news_meta post_time">2020-10-09span>
                        li>
                        <li class="news n3 clearfix">
                            <span class="news_title"><a href='/2020/1001/c34a45467/page.htm' target='_blank' title='我校开展“我们的节日——庆国庆 品月饼 话中秋”活动'>我校开展“我们的节日——庆国庆 品月饼 话中秋”活动a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                        <li class="news n4 clearfix">
                            <span class="news_title"><a href='/2020/1001/c34a45466/page.htm' target='_blank' title='民政与社会治理学院举行“月满中秋 心系民生”三关慰问会'>民政与社会治理学院举行“月满中秋 心系民生”三关慰问会a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                        <li class="news n5 clearfix">
                            <span class="news_title"><a href='/2020/1001/c34a45465/page.htm' target='_blank' title='民政与社会治理学院举办民政社工类专业校园招聘会'>民政与社会治理学院举办民政社工类专业校园招聘会a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                        <li class="news n6 clearfix">
                            <span class="news_title"><a href='/2020/1001/c34a45464/page.htm' target='_blank' title='重庆市首届“金融科技创新产品设计运营”竞赛赛前说明会在我校召开'>重庆市首届“金融科技创新产品设计运营”竞赛赛前说明会在我校召开a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                        <li class="news n7 clearfix">
                            <span class="news_title"><a href='/2020/1001/c34a45462/page.htm' target='_blank' title='我校举行2020年度重庆市教育规划课题开题报告会'>我校举行2020年度重庆市教育规划课题开题报告会a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                        <li class="news n8 clearfix">
                            <span class="news_title"><a href='/2020/1010/c34a45513/page.htm' target='_blank' title='我校与重庆市高新区公共服务局签订校地合作战略框架协议'>我校与重庆市高新区公共服务局签订校地合作战略框架协议a>span><span class="news_meta post_time">2020-09-30span>
                        li>
                    ul>
                div> 

            div>
        div>
        <div class="clear">div>
    div>
div>
<div class="wrapper con_bg" id="container">
    <div class="inner">
        
  	
        <div class="mod mod1">
             
    	
            <div class="ml" frag="面板3">
                  	
                <div class="post post-3 mbox" frag="窗口3">
                    <div class="tt">
                          	
                        <h3 class="tit">
                            <span class="title" frag="标题">媒体视角span>
                        h3>
                        <div class="more_btn" frag="按钮" type="更多">
                            <a href="/36/list.htm" class="w3_more"><span class="more_text" frag="按钮内容">更多>>span>a>
                        div>
                    div>
                    <div class="con">
                        <div id="wp_news_w3"> 

                            <ul class="news_list clearfix">
                                
                                <li class="news n1">
                                    <div class="news_title">
                                        <a href='/2020/1009/c36a45491/page.htm' target='_blank' title='[学习强国]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>[学习强国]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理a>
                                    div>
                                    <div class="news_time_b">
                                        <span class="time_l">重庆城市管理职业学院span><span class="time_r">2020-10-09span>
                                    div>
                                    <div class="news_jj">
                                        <a href='/2020/1009/c36a45491/page.htm' target='_blank' title='[学习强国]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>近日,康居西城公租房小区,穿着橙红色背心的重庆兴民社会工作服务中心项目主管李江渔与同事们就新启动的社工项目...a>
                                    div>
                                li>
                                <li class="news n2">
                                    <div class="news_title">
                                        <a href='/2020/1009/c36a45490/page.htm' target='_blank' title='[重庆日报]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>[重庆日报]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理a>
                                    div>
                                    <div class="news_time_b">
                                        <span class="time_l">重庆城市管理职业学院span><span class="time_r">2020-10-09span>
                                    div>
                                    <div class="news_jj">
                                        <a href='/2020/1009/c36a45490/page.htm' target='_blank' title='[重庆日报]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>相关链接:https://epaper.cqrb.cn/html/cqrb/2020-10/06/004/content_rb_271933.htma>
                                    div>
                                li>
                            ul>
                        div> 

                    div>
                div>
                <div class="mtsj" frag="窗口66">
                    <div class="con">
                        <div id="wp_news_w66"> 

                            <ul class="news_list">
                                
                                <li class="news n1 clearfix">
                                    <span class="news_title"><a href='/2020/1009/c36a45492/page.htm' target='_blank' title='[华龙网]重庆高校学生开展月饼DIY活动庆祝国庆中秋'>[华龙网]重庆高校学生开展月饼DIY活动庆祝国庆中秋a>span><span class="news_meta post_time">2020-10-09span>
                                li>
                                <li class="news n2 clearfix">
                                    <span class="news_title"><a href='/2020/1009/c36a45489/page.htm' target='_blank' title='[中国新闻网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>[中国新闻网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理a>span><span class="news_meta post_time">2020-10-09span>
                                li>
                                <li class="news n3 clearfix">
                                    <span class="news_title"><a href='/2020/1009/c36a45488/page.htm' target='_blank' title='[新华网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理 '>[新华网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理 a>span><span class="news_meta post_time">2020-10-09span>
                                li>
                                <li class="news n4 clearfix">
                                    <span class="news_title"><a href='/2020/1009/c36a45487/page.htm' target='_blank' title='[华龙网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理'>[华龙网]“增能”社区 “激活”居民 重庆高新区香炉山街道购买社工项目推进公租房小区治理a>span><span class="news_meta post_time">2020-10-09span>
                                li>
                            ul>
                        div> 

                    div>
                div>
            div>
        div>
        <div class="mod mod2">
            <div class="mc" frag="面板4">
                  	
                <div class="post post-4 mbox" frag="窗口4">
                    <div class="tt">
                          	
                        <h3 class="tit">
                            <span class="title" frag="标题">通知公告span>
                        h3>
                        <div class="more_btn" frag="按钮" type="更多">
                            <a href="/37/list.htm" class="w4_more"><span class="more_text" frag="按钮内容">更多>>span>a>
                        div>
                    div>
                    <div class="con">
                        <div id="wp_news_w4"> 

                            <ul class="news_list scroll">
                                
                                <li class="news n1 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-07span><span class="time_b">08span>span><span class="news_title"><a href='/2020/0708/c37a44500/page.htm' target='_blank' title='重庆城市管理职业学院2020-2021学年校历'>重庆城市管理职业学院2020-2021学年校历a>span>
                                li>
                                <li class="news n2 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">28span>span><span class="news_title"><a href='/2020/0928/c37a45413/page.htm' target='_blank' title='2020年国庆、中秋假期值班安排表'>2020年国庆、中秋假期值班安排表a>span>
                                li>
                                <li class="news n3 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">07span>span><span class="news_title"><a href='/2020/0907/c37a44927/page.htm' target='_blank' title='重庆城市管理职业学院2020-2021学年第1学期值班表'>重庆城市管理职业学院2020-2021学年第1学期值班表a>span>
                                li>
                                <li class="news n4 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-01span><span class="time_b">29span>span><span class="news_title"><a href='/2020/0129/c37a41642/page.htm' target='_blank' title='新型冠状病毒感染的肺炎防控知识手册'><font style='font-weight:bold;'>新型冠状病毒感染的肺炎防控知识手册font>a>span>
                                li>
                                <li class="news n5 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-10span><span class="time_b">09span>span><span class="news_title"><a href='/2020/1009/c37a45493/page.htm' target='_blank' title='关于举办2020年全国行业职业技能竞赛 全国连锁经营行业职业技能竞赛重庆市选拔赛的通知'>关于举办2020年全国行业职业技能竞赛 全国连锁经营行业职业技能竞赛重庆市选...a>span>
                                li>
                                <li class="news n6 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">29span>span><span class="news_title"><a href='/2020/0929/c37a45419/page.htm' target='_blank' title='会议通知'>会议通知a>span>
                                li>
                                <li class="news n7 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">25span>span><span class="news_title"><a href='/2020/0925/c37a45286/page.htm' target='_blank' title='会议通知'>会议通知a>span>
                                li>
                                <li class="news n8 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">24span>span><span class="news_title"><a href='/2020/0924/c37a45264/page.htm' target='_blank' title='重庆城市管理职业学院关于开展“我为学校‘十四五’规划提建议”活动的通知'>重庆城市管理职业学院关于开展“我为学校‘十四五’规划提建议”活动的通知a>span>
                                li>
                                <li class="news n9 clearfix">
                                    <span class="news_meta post_time"><span class="time_t">2020-09span><span class="time_b">22span>span><span class="news_title"><a href='/2020/0922/c37a45243/page.htm' target='_blank' title='重庆城市管理职业学院 关于2020年中秋节、国庆节放假安排 及疫情防控工作要求的通知'>重庆城市管理职业学院 关于2020年中秋节、国庆节放假安排 及疫情防控工作要求...a>span>
                                li>
                            ul>
                        div> 

                    div>
                div>
            div>
            <div class="clear">div>
        div>
        <div class="clear">div>
    div>
div>
<div class="clear">div>
<div class="wrapper" id="con_link">
    <div class="inner" frag="面板22">
        <div frag="窗口22">
              	
            <div id="wp_nav_w22"> 

 
<ul class="wp_nav" data-nav-config="{drop_v: 'down', drop_w: 'right', dir: 'y', opacity_main: '1', opacity_sub: '0.8', dWidth: '0'}">
      
     <li class="nav-item i1 "> 
         <a href="http://www.cswu.cn/49/list.htm" title="基层党建" target="_self"><span class="item-name">基层党建span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i2 "> 
         <a href="http://dc.cswu.cn/portal_main/toPortalPage" title="教务管理" target="_self"><span class="item-name">教务管理span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i3 "> 
         <a href="http://www.cswu.cn/rsc/" title="人事管理" target="_self"><span class="item-name">人事管理span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i4 "> 
         <a href="http://www.cswu.cn/54/list.htm" title="专题网站" target="_blank"><span class="item-name">专题网站span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i5 "> 
         <a href="http://www.cswu.cn/dzb/217/main.htm" title="信息公开" target="_blank"><span class="item-name">信息公开span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i6 "> 
         <a href="/_web/leadermail/intiWriteToLeaderMail.do?_p=YXM9MyZ0PTMmcD0xJm09TiY_&request_locale=zh_CN&localeCH=true" title="领导信箱" target="_blank"><span class="item-name">领导信箱span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i7 "> 
         <a href="/55/list.htm" title="新媒体平台" target="_self"><span class="item-name">新媒体平台span>a><i class="mark">i> 
          
     li> 
      
     <li class="nav-item i8 "> 
         <a href="/48/list.htm" title="友情链接" target="_self"><span class="item-name">友情链接span>a><i class="mark">i> 
          
     li> 
      
ul> 
 
 
 div>
        div>
    div>
div>
<div class="wrapper" id="footer">
    <div class="inner clearfix">
                    <div class="foot-img">
                     <a href="http://www.cqwa.gov.cn/" target="_blank"><img border="0" alt="重庆市公安局网络信息安全服务网" src="/_upload/tpl/00/03/3/template3/images/sentrybox.gif" width="50" height="65"/>a>
                    div>
                    <div class="foot-copy">
                        <div class="foot_link">
                            <p>
                                <span>国家示范性骨干高职院校span><span>全国职业教育先进单位span><span>全国普通高校毕业生就业工作先进集体span>
                            p>
                        div>
  	
                        <p class="copyright">
                            <span class="copy">版权所有©重庆城市管理职业学院span> <span>总访问量:<span frag="面板55"><span frag="窗口55"><img border="0" src="/_visitcountdisplay?siteId=3&type=1&dispMode=2&statMode=1" />span>span>span><span>今日访问量:<span frag="面板56"><span frag="窗口56"><img border="0" src="/_visitcountdisplay?siteId=3&type=1&dispMode=2&statMode=4" />span>span>span> <br/><span class="address">学校地址:重庆市沙坪坝区虎溪大学城南二路151号span><span>邮编:401331span><span>联系电话:(023)65626161(党政办)  (023)65626666(招生处)span><span>(<a href="http://beian.miit.gov.cn/" target="blank" style="color:#e3e3e3;">渝ICP备12001925号a>)span>
                        p>
                    div>
                    <div class="foot-box">
                    <div class="foot-l">
                        <script type="text/javascript">document.write(unescape("%3Cspan id='_ideConac' %3E%3C/span%3E%3Cscript src='http://dcs.conac.cn/js/04/000/0000/60686709/CA040000000606867090003.js' type='text/javascript'%3E%3C/script%3E"));script>
                    div>
    div>
div><script _ue_org_tagname="script" type="text/javascript">
$(function(){
    $(".slider").sudyfocus({
      p:28,
      zWidth:1600,
      zHeight:546,
      pagination: true,
	  response: true,
      title:{
		  active: false, // 是否显示标题
		isAutoWidth: false,
        href:true
      }
    });
  });script>
  <script type="text/javascript" src="/_upload/tpl/00/03/3/template3/js/app.js">script>
  <script type="text/javascript">
  $(function(){
	// 初始化SDAPP
	new SDAPP({
		'focus':{
			zWidth:1200,
			zHeight:500
		},
		"menu":{
			type:"aside,slide"
		}
	});
});script>
body>
html>
 <img src="/_visitcount?siteId=3&type=1&columnId=7" style="display:none" width="0" height="0">image>

- 正则表达式
(/\d{4}(?<=\d)){2}/[\w\d]+/page.htm

效果

/2016/0517/c68a5998/page.htm
/2017/0830/c65a26194/page.htm
/2020/0817/c65a44805/page.htm
/2020/0817/c65a44804/page.htm
/2020/0511/c65a42775/page.htm
/2020/0205/c65a41663/page.htm
/2020/0911/c33a45028/page.htm
/2020/0911/c33a45028/page.htm
/2020/0630/c33a44285/page.htm
/2020/0630/c33a44285/page.htm
/2020/0701/c33a44316/page.htm
/2020/0701/c33a44316/page.htm
/2020/0516/c33a42868/page.htm
/2020/0516/c33a42868/page.htm
/2020/1009/c34a45494/page.htm
/2020/1001/c34a45467/page.htm
/2020/1001/c34a45466/page.htm
/2020/1001/c34a45465/page.htm
/2020/1001/c34a45464/page.htm
/2020/1001/c34a45462/page.htm
/2020/0929/c34a45423/page.htm
/2020/0929/c34a45435/page.htm
/2020/1009/c36a45491/page.htm
/2020/1009/c36a45491/page.htm
/2020/1009/c36a45490/page.htm
/2020/1009/c36a45490/page.htm
/2020/1009/c36a45492/page.htm
/2020/1009/c36a45489/page.htm
/2020/1009/c36a45488/page.htm
/2020/1009/c36a45487/page.htm
/2020/0708/c37a44500/page.htm
/2020/0928/c37a45413/page.htm
/2020/0907/c37a44927/page.htm
/2020/0129/c37a41642/page.htm
/2020/1009/c37a45493/page.htm
/2020/0929/c37a45419/page.htm
/2020/0925/c37a45286/page.htm
/2020/0924/c37a45264/page.htm
/2020/0922/c37a45243/page.htm

-加一个零宽断言
(/\d{4}){2}/[\w\d]+(?=/page.htm)

效果如下

/2016/0517/c68a5998
/2017/0830/c65a26194
/2020/0817/c65a44805
/2020/0817/c65a44804
/2020/0511/c65a42775
/2020/0205/c65a41663
/2020/0911/c33a45028
/2020/0911/c33a45028
/2020/0630/c33a44285
/2020/0630/c33a44285
/2020/0701/c33a44316
/2020/0701/c33a44316
/2020/0516/c33a42868
/2020/0516/c33a42868
/2020/1009/c34a45494
/2020/1001/c34a45467
/2020/1001/c34a45466
/2020/1001/c34a45465
/2020/1001/c34a45464
/2020/1001/c34a45462
/2020/0929/c34a45423
/2020/0929/c34a45435
/2020/1009/c36a45491
/2020/1009/c36a45491
/2020/1009/c36a45490
/2020/1009/c36a45490
/2020/1009/c36a45492
/2020/1009/c36a45489
/2020/1009/c36a45488
/2020/1009/c36a45487
/2020/0708/c37a44500
/2020/0928/c37a45413
/2020/0907/c37a44927
/2020/0129/c37a41642
/2020/1009/c37a45493
/2020/0929/c37a45419
/2020/0925/c37a45286
/2020/0924/c37a45264
/2020/0922/c37a45243


附:常用字符

\s 空白符 \S 非空白符
\t 制表符(空白)
\r enter回车符
\n 换行符
\f 换页符

你可能感兴趣的:(大学积累,正则表达式)