import re with open("includes/layout/footer.php", "r") as f: content = f.read() new_body = """
""" content = re.sub( r'
\s*\s*\s*
\s* <\?php echo __\("excel_format_info"\); \?>\s*
\s*
', new_body, content ) with open("includes/layout/footer.php", "w") as f: f.write(content)