Chapter 3. Working with Regular Expressions

I would chooseTo lead him in a maze along the patterned paths...

—Amy Lowell, “Patterns”

The power of regular expressions as a computing tool has often been underestimated. From their earliest theoretical beginnings in the 1940s, they found their way onto computer systems in the 1960s and from there into various tools in the UNIX operating system. In the 1990s, the popularity of Perl helped make regular expressions a household programming item rather than the esoteric domain of bearded gurus.

The beauty of regular expressions is that almost everything in our experience can be understood in terms of patterns. Where there are patterns that we can describe, we can detect matches, we can find the pieces ...

Get The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.