|
|
|
Appendix B - Regular Expression Syntax
Regular Expression, often abbreviated regexp, is a standardized way to
make patterns that match certain strings. Normal characters, such as A
through Z only match themselves, but some characters have special meaning.
Pattern | Matches |
.
|
Any one character.
|
[abc]
|
a, b or c.
|
[a-z]
|
Any character a to z inclusive.
|
[^ac]
|
Any character except a and c.
|
(x)
|
x, where x might be any regexp.
|
x*
|
Zero or more occurrences of x, where x may be
any regexp.
|
x+
|
One or more occurrences of x, where x may be
any regexp.
|
x|y
|
x or y, where x and y may be any regexp.
|
xy
|
xy, where x and y may be any regexp.
|
^
|
Beginning of string, but no characters.
|
$
|
End of string, but no characters.
|
\<
|
The beginning of a word, but no characters.
|
\>
|
end of a word, but no characters.
|
Some examples:
Regexp | Matches |
[0-9]+
|
One or more numeric characters.
|
(foo)|(bar)
|
Either "foo" or "bar".
|
\.html$
|
Any string ending in ".html".
|
^\.
|
Any string starting with a period.
|
Note!
|
\ can be used to quote these characters in which case they
match themselves, nothing else.
|
|
|