Previous slide Next slide Back to the first slide View text version


Notes:

We have illustrated how UNIX regular expressions provide tremendous flexibility; with regards to how special characters are used to affect a portion (subexpression) of the complete expression. We can expand this further: when mastering the grouping of subexpressions within parentheses; then using a special spanning of characters operation..

In the first example, we’re not doing anything special other then looking for the word without. Notice there is no affect yet by grouping the substring out within parentheses. As a result, line 4 satisfies the match from the fortunes file.

The second illustrates what happens when we have the question mark (interpreted as have the expression work zero or more times) act on the subexpression out. Notice how we can now match the words with or without, by using a question mark (?) to span the grouping of the subexpression out. Based upon the expressions definition, lines 3, 4, 5, and 13 satisfies the pattern match.