Hello!

I just published a new version of "Understanding Python re(gex)?" ebook. I caught up to new features like possessive quantifiers, corrected many mistakes, improved examples, exercises and so on.

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 and the third-party regex module are covered in this book.


Release offers🔗

To celebrate the new release, you can download PDF/EPUB versions of Understanding Python re(gex)? for FREE till 05-Feb-2023. You can still pay if you wish ;)

Some of my ebook bundles are on sale as well:

info See also my blog post on how to customize pandoc for generating beautiful PDF/EPUB versions from GitHub style markdown.


What's new?🔗

  • Python version updated to 3.11
    • Possessive quantifiers and Atomic grouping are now supported by the re module
  • regex module
    • corrected examples and descriptions for \G and \K features
    • added railroad diagram for the recursive matching section
  • In general, many of the examples, exercises, solutions, descriptions and external links were updated/corrected
  • Updated Acknowledgements section
  • Code snippets related to info/warning sections will now appear as a single block
  • New section added for re(gex)? playground
  • Book title changed to Understanding Python re(gex)?
  • New cover image
  • Images centered for EPUB format

Videos🔗

On this blog, I post tips covering Python, command line tools and Vim. Here are video demos for these tips:


re(gex)? playground🔗

To make it easier to experiment, I wrote on an interactive app. See PyRegexPlayground repo for installation instructions and usage guide. A sample screenshot is shown below:

Sample screenshot from the Playground screen


re(gex)? exercises🔗

I wrote another 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. Here's a sample screenshot:

Sample screenshot for Python regex exercises


Table of Contents🔗

  1. Preface
  2. Why is it needed?
  3. re introduction
  4. Anchors
  5. Alternation and Grouping
  6. Escaping metacharacters
  7. Dot metacharacter and Quantifiers
  8. Interlude: Tools for debugging and visualization
  9. Working with matched portions
  10. Character class
  11. Groupings and backreferences
  12. Interlude: Common tasks
  13. Lookarounds
  14. Flags
  15. Unicode
  16. regex module
  17. Gotchas
  18. Further Reading

Web version🔗

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


GitHub repo🔗

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


Newsletter🔗

Subscribe to learnbyexample weekly — free newsletter covering programming resources, updates on what I am creating, tips, tools, free ebooks and more, delivered every Friday.


Feedback and Errata🔗

I would highly appreciate if you'd let me know how you felt about this book. It could be anything from a simple thank you, Gumroad rating, 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.

You can reach me via:

Happy learning :)