Please help! I am very new at this. I have a string of url’s of which I am trying to remove the same part of each one. For example:
old urls
http://cdn4.abc//uploads/thumbnails/30/421/test-url-link-HuEB5k.jpg
http://cdn4.abc//uploads/thumbnails/24/579/this-test-link-2-D3MnkU.jpg
Edited form remove end portion with text caption before .jpg
http://cdn4.abc//uploads/thumbnails/30/421/HuEB5k.jpg
http://cdn4.abc//uploads/thumbnails/24/579/D3MnkU.jpg
Heres what I am trying but I cant get all the urls to adjust to the same format
import_re
domain_str = 'http://cdn4.abc//uploads/thumbnails/30/421/test-url-link-HuEB5k.jpg, http://cdn4.abc//uploads/thumbnails/24/579/test-url-link-2-D3MnkU.jpg, http://cdn4.abc//uploads/thumbnails/30/421/test-url-link-3-kJ65Vbe.jpg'
matches = re.findall('(https?://w*.w*/?)',domain_str)
altered_domains = [re.sub("test-url-link-", domain_str)]
print(altered_domains)
New contributor
user25301068 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1