Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
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 if http
or https
is found[^)]+(?=\))
match non )
characters and assert that )
is present after those characters$&=~s|%20|-|gr
change %20
to -
for the matching portion found, the r
flag is used to return the modified string instead of change $&
itselflc
is a function to change text to lowercaseGNU 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)
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 wish you success. I’m happy to use SimpleScreenRecorder(https://github.com/MaartenBaert/ssr).
Why do you think it is a phishing link? Gumroad is a well known platform to sell digital goods.
I mention it is free up to some date because it will go back to being a paid product after that.
Is it regex or sed/awk syntax (or both) that gives you trouble?
I had similar reaction and didn’t even try to learn them for years - then I caught the stackoverflow craze of answering CLI questions (and learning from others).
oxipng, pngquant and svgcleaner for optimizing images
auto-editor for removing silent portions from video recordings
Not my blog, just sharing it here. Saw it on HN (https://news.ycombinator.com/item?id=40419325)
What’s the difference between two_percent and skim?
Check out https://novelwriter.io/
I’m not familiar with such softwares (I use pandoc for technical writing), but might help you…
Yeah, it is uncommon spelling, but if you google, you’ll find it’s not that rare ;)
You’re welcome, happy learning :)
I’m self-published and haven’t worked for other publications. Sometimes, my submissions reach HN front page, so you might have seen there or because others picked it up from there and shared around elsewhere.
As per the manual, “Mappings are set up to work like most click-and-type editors” - which is best suited with GUI Vim.
While Vim doesn’t make sense to use without the modes, there are plugins like https://github.com/tombh/novim-mode!
I had to learn Linux CLI tools, Vim and Perl at my very first job. Have a soft spot for Perl, despite not using it much these days other than occasional one-liners (mainly for advanced regex features).
Thanks a lot for the kind words! Means a lot to me :)
Well, if you are comfortable with Python scripts, there’s not much reason to switch to
awk
. Unless perhaps you are equatingawk
to Python as scripting languages instead of CLI usage (likegrep
,sed
,cut
, etc) as my ebook focuses on. For example, if you have space separated columns of data,awk '{print $2}'
will give you just the second column (no need to write a script when a simple one-liner will do). This of course also allows you to integrate with shell features (like globs).As a practical example, I use
awk
to filter and process particular entries from financial data (which is in csv format). Just a case of easily arriving at a solution in a single line of code (which I then save it for future use).