HTML and CSS Reference
In-Depth Information
Appendix A. Regular Expressions
Regular expressions enable one to search for common patterns in text files. Many tools support regular-
expression-based search and replace. Although there are small differences in syntax from one tool to the next,
most of the syntax and the basic ideas are much the same.
Characters That Match Themselves
The first rule of regular expressions is that most normal characters match themselves. A "normal" character is a
letter, a digit, or a space. Thus, the regular expression "Al Gore was elected president in the year 2000"
matches exactly the string "Al Gore was elected president in the year 2000" and no others. Searching for that
string will find all occurrences of that exact string in the searched document or documents. However, it will not
find even slight variations, such an extra space between the words Al and Gore . Table A.1 shows some more
Table A.1. Characters That Match Themselves
The string Foo
The string foo
foo bar
The string foo bar
foo bar
The string 2000
a e
The string a e
a e
The string <!DOCTYPE
The string <p>
The string </p>
To be specific, the following characters match themselves:
All ASCII letters A-Z and a-z
The ASCII digits 0-9
The space character
All non-ASCII characters: é, ç,... and so on
The following ASCII punctuation characters:
Search WWH ::

Custom Search