Chapter 8Regular Expressions Basics

We’ve looked now at a variety of ways that you can get text into your Ruby programs: from the user, from a pipe, from files. The next step, naturally, is to actually do something with that input.

When processing text, our aims can generally be split into three broad categories: testing, where we check whether the data matches a particular pattern; extraction, where we try to pull interesting information out of the data; and transformation, where we convert the data from one format to another. Often, we’ll want to do some combination of all three of these things: checking for particular formats, extracting key pieces of information, and then transforming them (converting them to a different text format, ...

Get Text Processing with Ruby 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.