I just published a new version of "Understanding JavaScript RegExp" ebook. Added examples for d and v flags, corrected many mistakes, improved examples, exercises and so on.

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

Release offers🔗

To celebrate the new release, you can download PDF/EPUB versions of Understanding JavaScript RegExp for FREE till 05-Nov-2023. You can still pay if you wish ;)

All Books Bundle is just $12 (normal price $32) — includes all my 13 programming ebooks.

What's new?🔗

  • Examples and exercises added for d and v flags
  • Strings in code snippets changed to be uniformly represented in single quotes
  • 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 JavaScript 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:


Literally was having a mini-breakdown about not understanding Regex in algorithm solutions the other day and now I'm feeling so much better, so thank YOU! I genuinely feel like I'm developing the skill for spotting when and where to use them after so much practice!

feedback on twitter

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. Unicode
  15. Further Reading

Web version🔗

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

GitHub repo🔗

Visit https://github.com/learnbyexample/learn_js_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, 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 :)