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


Notes:

In the first example, were matching those records (from the fortune file) that has an uppercase or lowercase vowel U anywhere on the line; followed by any three characters as noted with the period (match any character). Lines 2 thru 7; lines 10, 11, 17, 18; lines 20 thru 24; lines 27, 28; lines 30 thru 32; and lines 34 & 35 satisfy the match. This may be confusing at first, however, realize how these records satisfies the match. This is why all matches that satisfies the expression are underlined. This should help clear the confusion when realizing the expression states find an uppercase or lowercase u; followed by any three printable characters.

In the second example we’re going to first match a space; followed by an uppercase or lowercase U; followed by any three printable characters; and sixth character for this expression defined is the space character. Our effort here is to match four letter words spelled with an u as the first character of the word. Based upon the contents of the fortunes file, lines 6, 18, 24, 28, and 35 satisfy the pattern match.

With the use of periods, some anomalies (logic flaws could occur). For example, the string “ us. “ (a space followed by u, s, and the period; then followed by two spaces could satisfy this expression); as spaces qualify as printable characters. This is why you need to be as specific as you can!

A discussion on improving and refining expressions is discussed later.