Matching Groups of Characters
So far, so good? The regular expressions we've been building so far shouldn't strike you as being that complex, particularly if you look at each pattern in the way Perl does, character by character and alternate by alternate, taking grouping into effect. Now we're going to start looking at some of the shortcuts that regular expressions provide for describing and grouping various kinds of characters.
Say you had a string, and you wanted to match one of five words in that string: pet, get, met, set, and bet. You could do this:
That would work. Perl would search through the whole string for pet, then search through the whole string for get, then do the same thing for met, and ...