I have some markdown files with links like this one:
[Royal Enfield Flying Flea](RE Flying Flea)
And I'm trying to urlencode the second part of the link to become
[Royal Enfield Flying Flea](RE%20Flying%20Flea)
I'm using sed, which i think is the one tool best suited for the job. I already made some other transformations in the file using it. But I can use another, like awk if someone thinks it's better.
I also managed to capture the strings using sed -E 's/\[([A-Za-z0-9 ]*)\]\(([A-Za-z0-9 ]*)\)/\1\2/' but I couldn't found a ways to make substitution in the selected part. Only to show it as it is.
If someone can point me in the right path, I appreciate.
Using Perl and a proper module to percent escape URL:
Yields:
If you'd like to edit the file in place, use
-ioption:The regular expression matches as follows:
(\[.*?\])\((.*?)\)See URI::Escape