Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning Regular Expressions 2005.pdf
Скачиваний:
95
Добавлен:
17.08.2013
Размер:
25.42 Mб
Скачать

Chapter 12

How It Works

In Step 4. you specify the pattern [:digit:]?. Each time you click the Find button, a single numeric digit is matched. If you delete the ? character, there is no match.

When the pattern is [:digit:]*, the character sequences 123, 8, and 1234567890 are matched because the * character acts as a quantifier. The same character sequences are matched by the pattern [:digit:]+.

However, when the pattern is A[:digit:]B, the ? character is no longer needed for the POSIX character class to match a single numeric digit. The pattern matches the character sequence A8B only in the test text. If the ? character is added, as in the pattern A[:digit:]?B, both A8B and AB match.

Exercises

These exercises are intended to allow you to test your understanding of some of the material that you learned in this chapter:

1.Specify a character class that will match all uppercase alphabetic characters except W, X, Y, and Z.

2.Specify a character class that will match lowercase characters a through h and t through z.

304