I need a way to detect that there's a time in a string with a xx:xx format, extract that time, plug it into a url and then replace that time with a markdown hyperlink to the url.
So for example if the string contains '... 19:30 ...', I want to replace it with '[19:30](https://www.thetimezoneconverter.com/?t={hour}%3A{min}&tz=GMT%2B1&)' in the string. At the moment I'm using this loop to forcibly get the time, but I have no way to refer to the original time in the string, so I can replace it:
import time
field_entry = 'blah blah blah, event at 19:30, be there'
for element in field_entry.split():
try:
time_for_url = time.strptime(element, '%H:%M')
except:
pass
print(f'https://www.thetimezoneconverter.com/?t={time_for_url.tm_hour}%3A{time_for_url.tm_min}&tz=GMT%2B1&')
As usual I'm probably thinking about this the wrong way and over-complicating it, so I'd love to see a different route.