1 Regular expressions allow more specific queries then a simple query.
7 <td> compan(y|ies) </td>
8 <td> Search for <em>company</em> , <em>companies</em></td>
11 <td> (peter|paul) </td>
12 <td> Search for <em>peter</em> , <em>paul</em></td>
16 <td> Search for <em>bug</em> , <em>bugs</em> , <em>bugfix</em></td>
20 <td> Search for <em>Bag</em> , <em>bag</em></td>
24 <td> Second letter is a vowel. Matches <em>bag</em> , <em>bug</em> , <em>big</em></td>
28 <td> Second letter is any letter. Matches also <em>b&g</em></td>
32 <td> Matches any one letter (not a number and a symbol) </td>
35 <td> [^0-9a-zA-Z] </td>
36 <td> Matches any symbol (not a number or a letter) </td>
39 <td> [A-Z][A-Z]* </td>
40 <td> Matches one or more uppercase letters </td>
43 <td> [0-9][0-9][0-9]-[0-9][0-9]- <br /> [0-9][0-9][0-9][0-9] </td>
44 <td valign="top"> US social security number, e.g. 123-45-6789 </td>
48 Here is stuff for our UNIX freaks: <br /> (copied from 'man grep')
50 \c A backslash (\) followed by any special character is a
51 one-character regular expression that matches the spe-
52 cial character itself. The special characters are:
54 + `.', `*', `[', and `\' (period, asterisk,
55 left square bracket, and backslash, respec-
56 tively), which are always special, except
57 when they appear within square brackets ([]).
59 + `^' (caret or circumflex), which is special
60 at the beginning of an entire regular expres-
61 sion, or when it immediately follows the left
62 of a pair of square brackets ([]).
64 + $ (currency symbol), which is special at the
65 end of an entire regular expression.
67 . A `.' (period) is a one-character regular expression
68 that matches any character except NEWLINE.
71 A non-empty string of characters enclosed in square
72 brackets is a one-character regular expression that
73 matches any one character in that string. If, however,
74 the first character of the string is a `^' (a circum-
75 flex or caret), the one-character regular expression
76 matches any character except NEWLINE and the remaining
77 characters in the string. The `^' has this special
78 meaning only if it occurs first in the string. The `-'
79 (minus) may be used to indicate a range of consecutive
80 ASCII characters; for example, [0-9] is equivalent to
81 [0123456789]. The `-' loses this special meaning if it
82 occurs first (after an initial `^', if any) or last in
83 the string. The `]' (right square bracket) does not
84 terminate such a string when it is the first character
85 within it (after an initial `^', if any); that is,
86 []a-f] matches either `]' (a right square bracket ) or
87 one of the letters a through f inclusive. The four
88 characters `.', `*', `[', and `\' stand for themselves
89 within such a string of characters.
91 The following rules may be used to construct regular expres-
94 * A one-character regular expression followed by `*' (an
95 asterisk) is a regular expression that matches zero or
96 more occurrences of the one-character regular expres-
97 sion. If there is any choice, the longest leftmost
98 string that permits a match is chosen.
100 ^ A circumflex or caret (^) at the beginning of an entire
101 regular expression constrains that regular expression
102 to match an initial segment of a line.
104 $ A currency symbol ($) at the end of an entire regular
105 expression constrains that regular expression to match
106 a final segment of a line.
108 * A regular expression (not just a one-
109 character regular expression) followed by `*'
110 (an asterisk) is a regular expression that
111 matches zero or more occurrences of the one-
112 character regular expression. If there is
113 any choice, the longest leftmost string that
114 permits a match is chosen.
116 + A regular expression followed by `+' (a plus
117 sign) is a regular expression that matches
118 one or more occurrences of the one-character
119 regular expression. If there is any choice,
120 the longest leftmost string that permits a
123 ? A regular expression followed by `?' (a ques-
124 tion mark) is a regular expression that
125 matches zero or one occurrences of the one-
126 character regular expression. If there is
127 any choice, the longest leftmost string that
128 permits a match is chosen.
130 | Alternation: two regular expressions
131 separated by `|' or NEWLINE match either a
132 match for the first or a match for the
135 () A regular expression enclosed in parentheses
136 matches a match for the regular expression.
138 The order of precedence of operators at the same parenthesis
139 level is `[ ]' (character classes), then `*' `+' `?'
140 (closures),then concatenation, then `|' (alternation)and