美文网首页
Python 正则表达式(2)

Python 正则表达式(2)

作者: SateZheng | 来源:发表于2016-12-15 00:47 被阅读2次

python自带re模块提供了对正则表达式的支持

re模块主要用到的方法列举如下:

函数 描述
re.compile(pattern[, flags] 根据包含正则表达式的字符串创建模式对象
re.search(pattern, string[, flags]) 在字符串中寻找模式
re.match(pattern, string[, flags]) 在字符串的开始处中寻找匹配模式
re.split(pattern, string[, maxsplit=0]) 根据模式的匹配项来分割字符串
re.findall(pattern, string) 列出字符串中模式的所有匹配项
re.finditer(pattern, string[, flags]) 返回一个顺序访问每一个匹配结果(Match对象)的迭代器
re.sub(pat, repl, string[, count=0]) 将字符串中所有的 pat 的匹配项用 repl 替换
re.subn(pattern, repl, string[, count]) 返回 (sub(repl, string[, count]) 替换次数)。
re.escape(string) 将字符串中所有特殊正则表达式字符转义

相关文章

  • 正则表达式

    Python正则表达式初识(一) Python正则表达式初识(二) Python正则表达式初识(三) Python...

  • 1.正则表达式

    Python通过标准库中的re模块来支持正则表达式。 1. 正则表达式的基本符号 2. python实现正则表达式...

  • 正则表达式

    Python:正则表达式Python:正则表达式

  • 判断一个字符串是否是合法ip

    此题目可以使用正则表达式匹配或者字符串匹配方法进行判断 思路: python2.7正则表达式解法: python2...

  • Python正则表达式指南

    Python正则表达式指南 本文介绍了Python对于正则表达式的支持,包括正则表达式基础以及Python正则表达...

  • python爬虫学习-day7-实战

    目录 python爬虫学习-day1 python爬虫学习-day2正则表达式 python爬虫学习-day3-B...

  • Python 基础爬虫目录

    目录 python爬虫学习-day1 python爬虫学习-day2正则表达式 python爬虫学习-day3-B...

  • python爬虫学习-day5-selenium

    目录 python爬虫学习-day1 python爬虫学习-day2正则表达式 python爬虫学习-day3-B...

  • python爬虫学习-day6-ip池

    目录 python爬虫学习-day1 python爬虫学习-day2正则表达式 python爬虫学习-day3-B...

  • python爬虫学习-day3-BeautifulSoup

    目录 python爬虫学习-day1 python爬虫学习-day2正则表达式 python爬虫学习-day3-B...

网友评论

      本文标题: Python 正则表达式(2)

      本文链接:https://www.haomeiwen.com/subject/opuwmttx.html