Sample Header Ad - 728x90

Converting html anchors to markdown using sed regex

2 votes
2 answers
737 views
I've been slowly converting a blog of mine to markdown. The final thing to do is replacing all the html anchors with markdown. I've come up this sed regex, which for all intents and purposes should do what I want, but it doesn't. Source data: $ cat /tmp/test on reddit or Lifehacker Sed command: $ sed -r 's/(.*?)/[\2](\1)/g' /tmp/test on [Lifehacker](https://lifehacker.com/ " target="_blank" rel="noopener) What I want it to return: on [Reddit](https://reddit.com/) or [Lifehacker](https://lifehacker.com/ ")
Asked by devilkin (31 rep)
Apr 25, 2020, 09:52 AM
Last activity: Apr 5, 2025, 08:04 PM