You will find matches on four lines, as shown in Figure A-11. The preceding command line will work
correctly only if the
file is in the current directory. If it is in a different directory, you will
need to reflect that in the path for the file that you enter at the command line.
The next section combines the techniques that you have seen so far to find a combination of literally
expressed characters and a sequence of characters.
Matching Sequences of Different Characters
A common task in simple regular expressions is to find a combination of literally specified single charac-
ters plus a sequence of characters.
There is an almost infinite number of possibilities in terms of characters that you could test. This section
focuses on a very simple list of part numbers and look for part numbers with the code DOR followed by
three numeric digits. In this case, the regular expression should do the following:
Look for a match for uppercase
. If a match is found, check if the next character matches uppercase
that matches, next check if the following character matches uppercase
. If those three matches are pres-
ent, check if the next three characters are numeric digits.
Finding Literal Characters and Sequences of Characters
is the sample file for this example:
First, try it in OpenOffice.org Writer, remembering that you need to use the regular expression pattern
Open the file
in OpenOffice.org Writer, and open the Find And Replace
Dialog box by pressing Ctrl+F.
Check the Regular Expression check box and the Match Case check box.
Enter the pattern
in the Search For text box and click the Find All button.
Appendix A: Simple Regular Expressions
bapp01.qxd:bapp01 10:47 324