Appendix C:
REGEX coding.
Specifications:
^ |
A circumflex as the first character of the pattern forces matches to beginning of lines. |
$ |
A dollar as the last character of the pattern forces matches to end of lines. |
. |
A period anywhere in the string matches any single character. |
* |
A character followed by an asterisk matches zero or more occurrences of that character. |
+ |
A character followed by a plus sign matches one or more occurrences of that character. |
- |
A character followed by a minus sign optionally matches that character. |
[] |
A string enclosed in square brackets matches any character in that string, but no others. If the first character of the string is a circumflex the expression matches any character except the characters in the string. A range of characters may be specified by two characters separated by a -. |
\< |
A backslash followed by an opening < matches the beginning of a word. |
\> |
A backslash followed by a closing > matches the end of a word. |
\( |
A backslash followed by an opening ( describes the beginning of a tagged sub-expression (see Substitution Expressions, it has no effect on search-only expressions). |
\) |
A backslash followed by a closing ) describes the end of a tagged sub-expression (see Substitution Expressions, it has no effect on search-only expressions). |
\ |
A backslash folowed by any other character quotes that character. This allows a search for a character that is usually a regular expression specifier. |
| |
A pipe symbol is evaluated as an OR function. |
Examples:
^Windows |
matches all lines starting with Windows |
Grep$ |
matches all lines ending with Grep |
H..p |
matches all lines containing Help, Hoop, Harp, etc. |
^W.n |
matches all lines starting with Win, Won, etc. |
\$ |
matches a dollar sign |
fo* |
matches f, fo, foo, fooo, etc. |
fo+ |
matches fo, foo, fooo, etc. |
[xyz] |
matches x, y or z |
a[^xyz]c |
matches abc, arc and atc but not axc, ayc, or azc |
([0-9]) |
matches (0), (1), (2), (3), (4), (5), (6), (7), (8) and (9) |
([0-9]*) |
matches (), (0), (123), (2512), etc. |
\<[Aa].*\> |
matches any non-empty word beginning with either A or a |
Most recent revision: March 31, 1997
Copyright © 1997 , Brian H. Smither.
All Rights Reserved.
E-MAIL: Brian Smither