1. 查找正则表达式

    import re
    re_txt = re.compile(r'(\d)*.txt')
    m = re_txt.search(src)
    if not m == None:
        m.group(0) #complete str
        m.group(1) # first group string
    
  2. 匹配正则表达式

    if re.match(r'(\d)*.txt',path):
        print("match")
    else:
        print("not match")
    
  3. 分割正则表达式

    list = re.split(r'\d',string)   
    
  4. 替换正则表达式

    re.sub(r'\d*',rep,src)
    

https://docs.python.org/2/library/re.html

相关文章:

  • 2021-05-26
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-01-18
猜你喜欢
  • 2021-07-21
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2021-11-05
  • 2021-07-07
  • 2022-01-22
相关资源
相似解决方案