10 REGULAR EXPRESSIONS

Regular expressions are a very important topic in any programming language, but they are also one of the hardest to master, in my experience. The difficulties exist because, more than most other subjects, you’ll be faced with cryptic syntax, the need to memorize lots of symbols, and remembering that a symbol’s effect can change in certain contexts. And, after all that, the result may still not be foolproof! But this is not to dissuade you from taking on the challenge, only to reassure you that if you don’t pick up regular expressions at first, you’re not alone.

But what are regular expressions? Think of regular expressions as an elaborate system of comparing strings to patterns. You first identify a pattern based upon ...

Get Ruby: Visual Quickstart Guide 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.