Python正则表达式的基础知识回顾

一、re模块:
      (1)正则表达式的定义:正则表达式通常被用来检索、替换那些符合某个模式(规则)的文本
      (2)re模块是python语言中拥有全部的正则表达式功能的模块,每一次需要用到正则表达式的内容时,都需要引
              入这个模块
二、match() , search() , findall()函数
       1、match()函数
           (1)、函数的原型:match(pattern,string,flags)
               Python正则表达式的基础知识回顾_第1张图片
            (2)、match()函数的使用
              Python正则表达式的基础知识回顾_第2张图片
       2、search()函数
           (1)、函数的原型:search(pattern,string,flags),参数的含义参考match()中的参数
           (2)、search()函数的使用
             Python正则表达式的基础知识回顾_第3张图片
             Python正则表达式的基础知识回顾_第4张图片
       3、findall()函数
           (1)、函数的原型:findall(pattern,string,flags),参数的含义参考match()中的参数
           (2)、findall()函数的使用
             Python正则表达式的基础知识回顾_第5张图片
       4、match()、search()和findall()函数的区别
            Python正则表达式的基础知识回顾_第6张图片
三、正则表达式的元字符
       1、匹配单个字符的元字符
   Python正则表达式的基础知识回顾_第7张图片
       2、边界字符
      Python正则表达式的基础知识回顾_第8张图片
       3、匹配多个字符
      Python正则表达式的基础知识回顾_第9张图片

四、分组函数:group()和groups()
       Python正则表达式的基础知识回顾_第10张图片
       使用
       Python正则表达式的基础知识回顾_第11张图片
       

五、sub()和subn()
       Python正则表达式的基础知识回顾_第12张图片
       使用例子:
       Python正则表达式的基础知识回顾_第13张图片
      Python正则表达式的基础知识回顾_第14张图片

你可能感兴趣的:(Python)