I'm trying to parse an input that may either be a hyperlink or a hyperlink in markdown. I can easily check whether it's a hyperlink with ^https?://.+$
and use regexp.Match, but with markdown links it's a whole different rabbit hole for me.
I came across this regex ^\[([\w\s\d]+)\]\((https?:\/\/[\w\d./?=#]+)\)$
which I tried to modify to match only the markdown link but after having the last parantheses captured for some reason, I've just been looking at just matching the 2nd capture group, the link, with things like SubexpNames, FindStringIndex, FindSubmatch, Split and so on, but none of them seem to either capture what I'm looking for (sometimes they return the entire string anyway) or most likely I'm doing it wrong.
Here's what I'm looking for:
Input - [https://imgur.com/abc](https://imgur.com/bcd)
Should output the link - https://imgur.com/bcd
Here's my code so far: https://play.golang.org/p/OiJE3TvvVb6