Created
January 18, 2026 09:45
-
-
Save me-suzy/c2f57e504f755e17931f13dca3d5ca78 to your computer and use it in GitHub Desktop.
test-=00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| # Test content - exact ca în fișierul HTML | |
| content = ' <a href="https://neculaifantanaru.com/stiinta-de-care-se-leaga-numele-meu.html"><img src="index_files/flag_lang_ro.jpg" title="ro" alt="ro" width="28" height="19" /></a> <a href="https://neculaifantanaru.com/fr/qualites-d-un-leader.html">' | |
| # Pattern pentru a găsi și înlocui href-ul RO | |
| pattern = r'(<a [^>]*?href=")https://neculaifantanaru\.com/[^"]*?("[^>]*?><img[^>]*?flag_lang_ro\.jpg[^>]*?></a>)' | |
| new_url = 'https://neculaifantanaru.com/manuscrisul-viu-al-vesniciei.html' | |
| replacement = r'\1' + new_url + r'\2' | |
| print("Original content:") | |
| print(content) | |
| print("\nPattern:", pattern) | |
| print("New URL:", new_url) | |
| print("\nMatch found:", re.search(pattern, content) is not None) | |
| if re.search(pattern, content): | |
| match = re.search(pattern, content) | |
| print("Matched:", match.group(0)) | |
| result = re.sub(pattern, replacement, content) | |
| print("\nResult:") | |
| print(result) | |
| print("\nReplacement successful:", result != content) | |
| else: | |
| print("No match found!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment