python正则使用笔记

def remove_br(content):
    """去除两边换行符"""
    content = content.replace("<br>", "<br />").replace("<br >", "<br />")
    while re.findall("^<br />|<br />$", content):
        content = re.sub(r'^<br />|<br />$', "", content)
    return content


if __name__ == "__main__":
    s =  remove_br("<br><br>ab<br />c<br><br>")
    print s

http://www.runoob.com/python/python-reg-expressions.html 

.

相关文章:

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