with open('src/main/resources/templates/doctor.html', 'r', encoding='utf-8') as f: text = f.read() import re # Find the start of the dropdown buttons container match = re.search(r'--Theo chuyên khoa--.*?', text, re.DOTALL) if match: start_idx = text.rfind('', match.end()) + 9 print(text[start_idx:end_idx + 1000]) # Print the button and following content