Well, I'm not going to even try understanding the various features used in that sed
command. I do know how to use basic loops with labels, but I never bothered with all the buffer manipulation stuff. I'd rather use awk/perl/python for those cases.
learnbyexample
This might work, but I think it is best to not tinker further if you already have a working script (especially one that you understand and can modify further if needed).
perl -pe 's/\[[^]]+\]\((?!https?)[^#]*#\K[^)]+(?=\))/lc $&=~s:%20|\d\K\.(?=\d):-:gr/ge'
Hmm, OP mentioned "Only edit what’s between parentheses" - don't see anywhere that whole URL shouldn't be changed...
Here's a solution with perl
(assuming you don't want to change http/https after the start of (
instead of start of a line):
perl -pe 's/\[[^]]+\]\(\K(?!https?)[^)]+(?=\))/lc $&=~s|%20|-|gr/ge' ip.txt
e
flag allows you to use Perl code in the substitution portion.\[[^]]+\]\(\K
match square brackets and use\K
to mark the start of matching portion (text before that won't be part of$&
)(?!https?)
don't match ifhttp
orhttps
is found[^)]+(?=\))
match non)
characters and assert that)
is present after those characters$&=~s|%20|-|gr
change%20
to-
for the matching portion found, ther
flag is used to return the modified string instead of change$&
itselflc
is a function to change text to lowercase
GNU datamash (https://www.gnu.org/software/datamash/alternatives/) - handy tool for data munching. There's also https://github.com/BurntSushi/xsv
Check out my chapter on GNU grep BRE/ERE for those wanting to learn this regex flavor: https://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html (there's also another chapter for PCRE)
Memory, Sorrow, and Thorn by Tad Williams
I use Vim ;)
Python itself provides IDLE, which is good enough for beginners. https://thonny.org/ is another good one for beginners.
As mentioned by others, Jetbrains is good for many languages. https://www.kdevelop.org/ is another option.
I'm not the site author, just submitting the link.
Not sure which part you need to be logged in to view - I'm seeing links to different articles and exercises and they are all visible without logging (I checked in an incognito window).
Not my site, just sharing a link I saw on HN.