<< Previous page                  Page 2 of 10               Next Page >>


L A P I S

Named Patterns



Another simple pattern is a named pattern. A named pattern is a pattern that has been saved with a name. Typing the name into the Pattern box runs the saved pattern. For example, here is a named pattern that selects all the U.S. state names and abbreviations found in the page:
 
State
Notice that there are no quotes around it. We're not looking for literal occurrences of the word state; rather, we're looking for matches to a more complicated pattern that was saved with the name State.

Try typing or copying the pattern above into the Pattern box and press Go to see what it selects in the following addresses.
Jared L. Cohon
Carnegie Mellon University
5000 Forbes Ave
Pittsburgh PA 15213

Charles M. Vest
Massachusetts Institute of Technology
77 Massachusetts Ave
Cambridge MA 02139
All named patterns are shown in the pane at the right of this window, which looks like this:
tutorial14
You can explore this list to find built-in patterns that may be useful for solving problems. The names are divided into categories and subcategories. To open or close a category, just click on the knob next to it. Clicking on a name displays the saved selection, just as if you had typed it into the Pattern box. The number in parentheses represents the number of pattern matches found for the given pattern.

Many named patterns (like State) are built-in, but you can also name your own patterns. You can name the last pattern you ran by clicking on the little Add... button. The Add button pops up a dialog box asking for a name:

    
Try the following exercise to see how the Add button works. First, make a simple selection by entering this pattern into the Pattern box and pressing Go. (If you're tired of pressing the Go button, you can just press Enter to do the same thing.)
"you"
Then press the Add button, and type Pronoun as the name for the selection. After you click OK, you should see Pronoun appear in the list of names. (Note: a more complete definition for Pronoun would selection not only you, but also other pronouns like I, he, she, and it. We'll see how to write more sophisticated patterns shortly.)
You can also name a selection by using the word is in a pattern. For example, typing the following pattern into the Pattern box would have the same effect as the steps you did above:
Pronoun is "you"
Names should not contain spaces or quotes, but otherwise you're free to choose any names you like. Uppercase or lowercase doesn't matter, so Pronoun means the same as pronoun and PRONOUN.


<< Previous page                  Page 2 of 10               Next Page >>


Go to the LAPIS home page.
Send comments or questions to Rob Miller, (rcm@lcs.mit.edu)
Copyright © 2003 - Massachusetts Institute of Technology. All Rights Reserved.