Let's say I have several <a> elements in string:
s = 'Hello world. <a href="https://stackoverflow.com/">StackOverflow</a> is a great website. <a href="https://www.espn.com/">ESPN</a> is another great website.'
The goal is to split the string so I get a list similar to the one below:
l = [
"Hello world. ",
{"link": "https://stackoverflow.com/", "title": "StackOverflow"},
" is a great website. ",
{"link": "https://www.espn.com/", "title": "ESPN"},
" is another great website.",
]
The dictionaries can be any object I can extract the link and title from. Is there a regex I can use to accomplish this? Or is there a better way to do this?