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()
    """
    

      

  • 相关阅读:
    OLEDB 枚举数据源
    OLEDB 调用存储过程
    OLEDB 参数化查询
    多结果集IMultipleResult接口
    使用pyh生成HTML文档
    数据更新接口与延迟更新
    SQL语句执行与结果集的获取
    事务对象和命令对象
    DNS练习之反向解析
    DNS练习之正向解析
  • 原文地址:https://www.cnblogs.com/DC0307/p/10447035.html
Copyright © 2011-2022 走看看