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

Regular Expressions and Microsoft Access

8.Save and close the query you have just created, naming it Find H?ll in ItemAuthor.

9.Double-click Find H?ll in ItemAuthor to run the query.

Figure 18-14 shows the results. Notice that the names Heller, Hill, Hills, and Hall match the pattern *H?ll*, because each of those author names contains an H character followed by some character (which the ? metacharacter matches), followed by the character sequence ll. The presence of the * metacharacter at both the beginning and the end of the pattern specifies that the matching four-character sequences can be preceded or followed by any sequence of characters or none at all.

Figure 18-14

Using the * Metacharacter

The * metacharacter matches zero or more characters.

The query Find a sequence in ItemAuthor is a parameter query that allows the user to enter a string that matches all or part of an author name. The construction of the query is very similar to the parameter query Find a sequence in ItemTitle described in detail earlier in this chapter, so the step-by-step creation is not described here for reasons of space.

In the second column from the left in the design window, the ItemAuthor column should be selected, and the following code should be entered in the Criteria row:

Like “*” & [Enter a character sequence:] & “*”

The regular expression pattern is constructed dynamically after the user enters a character sequence in the text box of the Enter Parameter Value dialog box. So if the user enters the character sequence Hill, the pattern becomes *Hill*. Or if the user enters the character sequence Mark, the pattern becomes *Mark*.

Double-click the Find a sequence in ItemAuthor query. Enter the character sequence Mark in the text box in the Enter Parameter Value dialog box. The results displayed are shown in Figure 18-15.

Each of the returned rows of data contains the character sequence Mark in the ItemAuthor column. As it happens, both results consist of the character sequence Mark Twain. So the first * metacharacter in the pattern *Mark* matches exactly zero characters, and the second * metacharacter matches the character sequence of space character followed by Twain.

423