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
.
时间: 2024-12-04 18:00:26