zoukankan      html  css  js  c++  java
  • 2 27re.py

    """
    匹配目标
    """
    # import re
    # content = 'Hello 123 4567 World_This is a Regex Demo'
    # result = re.match("^Hellos(d+)sWorld$", content)
    # print(result.group(1))
    """
    通用匹配
    """
    # import re
    # content = 'Hello 123 4567 World_This is a Regex Demo'
    # result = re.match("^Hello.*Demo$", content)
    # print(result)
    """
    贪婪与非贪婪
    """
    # import re
    # content = 'Hello 123 4567 World_This is a Regex Demo'
    # # result = re.match("^He.*?(d+).*Demo$", content)
    # result = re.match("^He.*(d+).*Demo$", content)
    # print(result)
    # print(result.group(1)) #group()和group(0)效果一样
    
    # import re
    # content = "http://weibo.com/comment/kEraCN"
    # result1 = re.match("^http.*?comment/(.*?)", content)
    # result2 = re.match("^http.*?comment/(.*?)$", content)
    # result3 = re.match("^http.*?comment/(.*)", content)
    # result4 = re.match("^http.*?comment/(.*)$", content)
    # print(result1.group(1))
    # print(result2.group(1))
    # print(result3.group(1))
    # print(result4.group(1))
    """
    修饰符
    """
    # re.I re.S
    """
    转义匹配
    """
    # /
    """
    search()
    """
    # import re
    # content = "http://weibo.com/comment/kEraCN"
    # result = re.search("tp.*?comment/(.*?)$", content)
    # print(result.group(1))
    """
    findall() sub() compile()
    """
    

      

  • 相关阅读:
    hdu 1978 How many ways
    hdu 2209 翻纸牌游戏
    hdu 2149 Public Sale (博弈规律题)
    CF 353C Find Maximum #205 (Div. 2)
    barrier and Fence
    window coordinate
    GPU hang
    the application was unable to start correctly 0xc000007b
    vertex buffer 数据结构 如何读vb的memory pool
    map
  • 原文地址:https://www.cnblogs.com/DC0307/p/10447035.html
Copyright © 2011-2022 走看看