Regular Expressions for All: Comprehensive Guide
This book is a thorough introduction to regular expressions, from the basic concepts through practical use cases to advanced techniques. It’s written for developers, data scientists, and anyone else who works with text processing and pattern matching.
Table of contents
Trying the examples
Most patterns in chapters 2 to 4 have a Try it button under them. It opens a small tester with some sample text, where you can change the pattern or the text and see every match. The tester uses PCRE2, the engine behind PHP’s preg_ functions and regex101’s default flavor, so even the recursion, atomic groups and conditionals in chapter 4 work. Everything runs in your browser; the engine, about 105 KB, downloads the first time you open a tester.
To work on your own patterns, try the Regex Tester on the companion tools site. It highlights matches and capture groups as you type and previews replacements, using JavaScript’s regex engine, the one in browsers and Node.js. JavaScript has no recursion, atomic groups or conditionals, so use the Try it buttons for the chapter 4 patterns that need them.
Getting Started
To get started with the book, simply click on the links above to access each chapter. You can read the chapters directly on GitHub or clone the repository to your local machine to read offline.
Contributing
If you find any errors or have suggestions for improvement, feel free to open an issue or submit a pull request. Contributions are welcome and encouraged!
License
This book is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are free to share and adapt the content for non-commercial purposes, as long as you give appropriate credit and share your adaptations under the same license.
Acknowledgments
Special thanks to all contributors who have helped make this book possible.