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
.