O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Repetition

Often we find that some part of a string is unimportant, and what is before and after it is all that we really care about. Placing wildcard dots in that in-between part of a regular expression is fine, as long as we know ahead of time how far apart the relevant pieces are; but we can't always count on that. Suppose we want to locate lines of HTML that contain italic text, enclosed between the start-italics tag <i> and the end-italics tag </i>.

But you <i>must</i> pay the rent!

The regex /<i>....<\/i>/ would identify the above line as containing some italicized chunk four letters long. That's too specific to be useful; if that were the best we could do, we'd have to test each line against a whole lot of regular expressions before ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required