O'Reilly logo

Learning Regular Expressions, First Edition by Ben Forta

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

Lesson 7

Using Subexpressions

Metacharacters and character matching provide the basic power behind regular expressions, as has been demonstrated in the lessons thus far. In this lesson you’ll learn how to group expressions together using subexpressions.

Understanding Subexpressions

Matching multiple occurrences of a character was introduced in Lesson 5, “Repeating Matches.” As discussed in that lesson, \d+ matches one or more digits, and https?:// matches http:// or https://.

In both of these examples (and indeed, in all the examples thus far) the repetition metacharacters (? or * or {2}, for example) apply to the previous character or metacharacter.

For example, HTML developers often place nonbreaking spaces (using  ) between words to ...

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