I just published a new version of the "Understanding Ruby Regexp" ebook. Corrected examples and descriptions for Atomic grouping, \G and \K features, improved examples, exercises and so on.

This book will help you learn Ruby Regular Expressions step-by-step from beginner to advanced levels with hundreds of examples and exercises.

You can download the PDF/EPUB versions of the book for free using the below links (you can also pay if you wish):

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

What's new?🔗

  • Ruby version updated to 3.3.0
  • Corrected examples and descriptions for Atomic grouping, \G and \K features
  • 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
  • Book title changed to Understanding Ruby Regexp
  • New cover image
  • Images centered for EPUB format


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

Table of Contents🔗

  1. Preface
  2. Why is it needed?
  3. Regexp 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. Modifiers
  15. Unicode
  16. Further Reading

GitHub repo🔗

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

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


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

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, 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 :)