美文网首页
Python 正则例子

Python 正则例子

作者: 闫_锋 | 来源:发表于2018-07-17 18:50 被阅读6次
print(re.search(r"r[A-Z]n", "dog runs to cat"))     # None
print(re.search(r"r[a-z]n", "dog runs to cat"))     # <_sre.SRE_Match object; span=(4, 7), match='run'>
print(re.search(r"r[0-9]n", "dog r2ns to cat"))     # <_sre.SRE_Match object; span=(4, 7), match='r2n'>
print(re.search(r"r[0-9a-z]n", "dog runs to cat"))  # <_sre.SRE_Match object; span=(4, 7), match='run'>

https://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html

相关文章

  • Python 正则例子

    https://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html

  • 正则表达式

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

  • 正则表达式

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

  • Python正则表达式指南

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

  • python正则表达式2

    python正则表达式2 re.match()匹配多个 例子: 输出: 表达式1 的匹配结果可以使用 matchO...

  • python正则学习

    一、常用的匹配规则总结表 原文链接 相关具体应用例子,请见:Python-正则表达式 二、re库中常用方法 相关具...

  • Python爬虫(十)_正则表达式

    本篇将介绍python正则表达式,更多内容请参考:【python正则表达式】 什么是正则表达式 正则表达式,又称规...

  • python正则表达式

    本篇将介绍python正则表达式,更多内容请参考:【python正则表达式】 什么是正则表达式 正则表达式,又称规...

  • sed

    常用例子 -r 正则 -i 修改文件

  • python 正则匹配中文

    # python 正则匹配中文 >``` #!/usr/bin/env python # -*- coding: ...

网友评论

      本文标题:Python 正则例子

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