Ajax software
Free javascripts
↑
Main Page
The text
DOR234
and
DOR123
is highlighted, indicating that those are matches for the regular expression.
The regular expression engine first looks for the literal character uppercase
D
. Each character is examined in
turn to determine if there is or is not a match.
If a match is found, the regular expression engine then looks at the next character to determine if the follow-
ing character is an uppercase
O
. If that too matches, it looks to see if the third character is an uppercase
R
. If
all three of those characters match, the engine next checks to see if the fourth character is a numeric digit.
If so, it checks if the fifth character is a numeric digit. If that too matches, it checks if the sixth character is a
numeric digit. If that too matches, the entire regular expression pattern is matched. Each match is displayed
in OpenOffice.org Writer as a highlighted sequence of characters.
You can check the
PartNumbers.txt
file for lines that contain a match for the pattern
DOR[0-9][0-9][0-9]
using the
findstr
utility from the command line, as follows:
findstr /N DOR[0-9][0-9][0-9] PartNumbers.txt
As you can see in Figure A-12, lines containing the same two matching sequences of characters,
DOR234
and
DOR123
, are matched. If the directory that contains the file
PartNumbers.txt
is not the current directory in
the command window, you will need to adjust the path to the file accordingly.
The Komodo Regular Expression Toolkit can also be used to test the pattern
DOR\d\d\d
. As you can see in
Figure A-13, the test text
DOR123
matches.
Figure A-12
Figure A-13
325
Appendix A: Simple Regular Expressions
bapp01.qxd:bapp01 10:47 325
Ajax software
Free javascripts
→