Python regular expression cheatsheet and examples
This blog post gives an overview and examples of regular expression syntax as implemented by the re
built-in module (Python 3.13+). Assume ASCII character set unless otherwise specified. This post is an excerpt from my Understanding Python re(gex)? book.
Visualization created using debuggex for the pattern r'\bpar(en|ro)?t\b'
Customizing pandoc to generate beautiful pdf and epub from markdown
Either you've already heard of pandoc
or if you have searched online for markdown
to pdf
or similar, you are sure to come across pandoc
. This tutorial will help you use pandoc
to generate pdf
and epub
versions from a GitHub style markdown file.
The main motivation for this blog post is to highlight the customizations I used for self-publishing my ebooks. It wasn't easy to arrive at the setup I ended up with, so I hope this will be useful for those looking to use pandoc
for such a purpose. This guide is specifically aimed at technical books that has code snippets.
Poster created using Canva
Everything you need to know about sed substitution
The command name sed
is derived from stream editor. The most commonly used editing command is substitution, for which various examples are shown in this blog post.
The examples presented here have been tested with
GNU sed
. Syntax and features might differ for other implementations.
CLI text processing with GNU awk book announcement
Hello!
I am pleased to announce a new version of my CLI text processing with GNU awk ebook.
Learn the GNU awk
command step-by-step from beginner to advanced levels with hundreds of examples and exercises. This book will dive deep into field processing, show examples for filtering features, multiple file processing, how to construct solutions that depend on multiple records, how to compare records and fields between two or more files, how to identify duplicates while maintaining input order and so on. Regular expressions will also be discussed in detail.
awk idioms explained
Do you find awk
one-liners cryptic? Stuff like !a[$0]++
, 1
, $1=$1
, NR==FNR
and -v RS=
? You'll find examples and brief explanations for such idioms in this post.
The examples presented here have been tested with
GNU awk
. These are likely to work with most other implementations ofawk
as well.
Understanding Python re(gex)? book announcement
Hello!
I just 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. The standard library re
as well as the third-party regex
module are covered in this book.
Coloring matched portions with GNU grep, sed and awk
You might already know how to use the --color
option to highlight matched portions with GNU grep
. In this post, you'll see how to use ANSI escape sequences to format matched portions with GNU sed
and GNU awk
.
100 Page Python Intro book announcement
Hello!
I am pleased to announce a new version of my 100 Page Python Intro ebook. This book is a short, introductory guide for the Python programming language. This book is well suited:
- As a reference material for Python beginner workshops
- If you have prior experience with another programming language
- If you want a complement resource after reading a Python basics book, watching a video course, etc
Festive offers for books on Python, Linux, Regular Expressions, Vim and more!
Hello!
Here are some awesome deals for programming books and courses during the 2024 festive season.