import re html_path = 'app/templates/admin.html' replacement_path = 'replacement_fa.txt' with open(html_path, 'r') as f: content = f.read() with open(replacement_path, 'r') as f: new_icons_block = f.read() # Regex to find the block pattern = r'const homelabIcons = \[.*?\];.*?\s*const fontawesomeIcons = \[.*?\];' if re.search(pattern, content, re.DOTALL): new_content = re.sub(pattern, new_icons_block, content, flags=re.DOTALL) with open(html_path, 'w') as f: f.write(new_content) print("Successfully replaced icon lists.") else: print("Could not find the icon lists block to replace.")