learnbyexample

joined 2 years ago
[–] learnbyexample 1 points 47 minutes ago

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 2 points 2 days ago (2 children)

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'
[–] learnbyexample 1 points 5 days ago (1 children)

Hmm, OP mentioned "Only edit what’s between parentheses" - don't see anywhere that whole URL shouldn't be changed...

[–] learnbyexample 2 points 5 days ago* (last edited 5 days ago) (7 children)

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 $& itself
  • lc is a function to change text to lowercase
135
FFmpeg By Example (ffmpegbyexample.com)
36
Understanding Memory Management (educatedguesswork.org)
 

Hello!

I recently published a new version of my Understanding Python re(gex)? ebook.

This book will help you learn Python Regular Expressions step-by-step from beginner to advanced levels with hundreds of examples and exercises. In addition to the standard library re, the third-party regex module is also covered in this book.

Release offers

To celebrate the new release, you can download the PDF/EPUB versions for free till 31-Jan-2025:

Interactive TUI app

I wrote a TUI app to help you solve exercises from this book interactively. See PyRegexExercises repo for installation steps and app_guide.md for instructions on using this app.

See my blog post Python regex cheatsheet for a quick reference.

Web version and GitHub repo

You can read the book online here: https://learnbyexample.github.io/py_regular_expressions/

Visit https://github.com/learnbyexample/py_regular_expressions for markdown source, example files, exercise solutions, sample chapters and other details related to the book.

Feedback and Errata

I would highly appreciate it if you'd let me know how you felt about this book. It could be anything from a simple thank you, rating/review, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.

Happy learning :)

[–] learnbyexample 7 points 1 month ago (1 children)
[–] learnbyexample 3 points 1 month ago

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)

[–] learnbyexample 2 points 1 month ago

Memory, Sorrow, and Thorn by Tad Williams

[–] learnbyexample 4 points 1 month ago

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.

22
Python Resources for Everybody (learnbyexample.github.io)
submitted 1 month ago by learnbyexample to c/python
[–] learnbyexample 6 points 1 month ago

I wish you success. I'm happy to use SimpleScreenRecorder(https://github.com/MaartenBaert/ssr).

[–] learnbyexample 2 points 2 months ago (1 children)

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).

[–] learnbyexample 1 points 5 months ago

I have a list of learning resources for CLI tools and scripting here: https://learnbyexample.github.io/curated_resources/linux_cli_scripting.html

I've also written a few TUI interactive apps to practice text processing commands like grep, sed, awk, coreutils, etc: https://github.com/learnbyexample/TUI-apps

view more: next ›