美文网首页
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.haomeiwen.com/subject/mzmgpftx.html