Awesome
Understanding Ruby Regexp
Learn Ruby Regular Expressions step-by-step from beginner to advanced levels with hundreds of examples and exercises. Visit https://youtu.be/QNsCzVeZH78 for a short video about the book.
<p align="center"><img src="./images/ruby_regexp_ls.png" alt="Understanding Ruby RegExp ebook cover image" /></p>The book also includes exercises to test your understanding, which are presented together as a single file in this repo — Exercises.md.
For solutions to the exercises, see Exercise_solutions.md.
See Version_changes.md to keep track of changes made to the book.
<br>E-book
- 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 get the book as part of these bundles:
- All books bundle bundle from https://learnbyexample.gumroad.com/l/all-books
- Includes all my programming books
- Awesome Regex bundle from https://learnbyexample.gumroad.com/l/regex or https://leanpub.com/b/regex
- Ruby text processing bundle from https://learnbyexample.gumroad.com/l/ruby-textprocessing or https://leanpub.com/b/ruby-textprocessing
- All books bundle bundle from https://learnbyexample.gumroad.com/l/all-books
- See https://learnbyexample.github.io/books/ for a list of other books
For a preview of the book, see sample chapters.
The book can also be viewed as a single markdown file in this repo. See my blogpost on generating pdfs from markdown using pandoc if you are interested in the ebook creation process.
For the web version of the book, visit https://learnbyexample.github.io/Ruby_Regexp/
<br>Feedback
⚠️ ⚠️ Please DO NOT submit pull requests. Main reason being any modification requires changes in multiple places.
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, 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:
- Issue Manager: https://github.com/learnbyexample/Ruby_Regexp/issues
- E-mail:
echo 'bGVhcm5ieWV4YW1wbGUubmV0QGdtYWlsLmNvbQo=' | base64 --decode
- Twitter: https://twitter.com/learn_byexample
Table of Contents
- Preface
- Why is it needed?
- Regexp introduction
- Anchors
- Alternation and Grouping
- Escaping metacharacters
- Dot metacharacter and Quantifiers
- Interlude: Tools for debugging and visualization
- Working with matched portions
- Character class
- Groupings and backreferences
- Interlude: Common tasks
- Lookarounds
- Modifiers
- Unicode
- Further Reading
Acknowledgements
- ruby-lang documentation — manuals and tutorials
- /r/ruby/ and /r/regex/ — helpful forum for beginners and experienced programmers alike
- stackoverflow — for getting answers to pertinent questions on Ruby and regular expressions
- tex.stackexchange — for help on pandoc and
tex
related questions - canva — cover image
- Warning and Info icons by Amada44 under public domain
- oxipng, pngquant and svgcleaner — optimizing images
- gmovchan for spotting a typo
- KOTP for spotting grammatical mistakes
- mdBook — for web version of the book
- mdBook-pagetoc — for adding table of contents for each chapter
- minify-html — for minifying html files
Special thanks to Allen Downey, an attempt at translating his book Think Python to Think Ruby gave me the confidence to publish my own book.
<br>License
The book is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The code snippets are licensed under MIT, see LICENSE file.