I have a string that is holding a URL:
url = http://example.com/1234/hello/
I wish to replace "hello" with "goodbye"
Thank you in advance!
Best Regards
Edit: My apologies, the example I used had a lot of placeholders. For extra clarification, "1234" and "hello" are dynamic and change a lot, so I need a method to replace everything after the 4th "/", if you will.
So far I've tried this, but it deleted the slashes and numbers:
url = re.search(r'(\A.*)0/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)1/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)2/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)3/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)4/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)5/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)6/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)7/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)8/',url,re.DOTALL|re.IGNORECASE).group(1)
url = re.search(r'(\A.*)9/',url,re.DOTALL|re.IGNORECASE).group(1)