Regular Expressions for Regular Folk

This is an experimental “book” about regular expressions. It is largely visual and example-based, as opposed to most regex resources I found while I was learning. I also attempted to choose test cases that highlight some common gotchas. I think it’ll be worth your time.

Screenshot from /chapters/escapes

This book’s intended audience is regex beginners. Some programming experience is assumed. It does not go into advanced regex concepts like engine backtracking and recursive regexes—at least not at the moment.

This is also an open source project, and contributions are welcome.

Contents

  1. Introduction
  2. Basics
  3. Character Classes
  4. Character Escapes
  5. Escapes
  6. Groups
  7. Repetition
  8. Alternation
  9. Flags
  10. Anchors
  11. Lookaround
  12. Advanced Examples
  13. Next Steps

Printing

A single-page version of the book is available. Print it ordinarily. Make sure to enable “Print Background Colors” on Firefox and “Background graphics” (under “More settings”) on Chrome.