10
10
regexp_table - format of Postfix regular expression tables
13
<b>postmap -fq "</b><i>string</i><b>" <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i>
13
<b>postmap -q "</b><i>string</i><b>" <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i>
15
<b>postmap -fq - <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i>
15
<b>postmap -q - <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i>
18
18
The Postfix mail system uses optional tables for address
19
rewriting or mail routing. These tables are usually in <b>dbm</b>
19
rewriting, mail routing, or access control. These tables
20
are usually in <b>dbm</b> or <b>db</b> format.
22
22
Alternatively, lookup tables can be specified in POSIX
23
23
regular expression form. In this case, each input is com-
24
pared against a list of patterns, and when a match is
25
found the corresponding result is returned.
24
pared against a list of patterns. When a match is found,
25
the corresponding result is returned and the search is
27
To find out what types of lookup tables your Postfix sys-
28
To find out what types of lookup tables your Postfix sys-
28
29
tem supports use the "<b>postconf -m</b>" command.
30
To test lookup tables, use the "<b>postmap -fq</b>" command as
31
To test lookup tables, use the "<b>postmap -q</b>" command as
31
32
described in the SYNOPSIS above.
35
With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>"
36
to query a table that contains case sensitive patterns.
37
Patterns are case insensitive by default.
33
39
<b>TABLE FORMAT</b>
34
40
The general form of a Postfix regular expression table is:
57
63
<b>endif</b> Match the input string against the patterns between
58
64
<b>if</b> and <b>endif</b>, if and only if that same input string
59
does <b>not</b> match <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.
65
does <b>not</b> match <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.
60
66
matches <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.
62
Note: do not prepend whitespace to patterns inside
68
Note: do not prepend whitespace to patterns inside
63
69
<b>if</b>..<b>endif</b>.
65
71
This feature is available in Postfix 2.1 and later.
67
73
blank lines and comments
68
Empty lines and whitespace-only lines are ignored,
69
as are lines whose first non-whitespace character
74
Empty lines and whitespace-only lines are ignored,
75
as are lines whose first non-whitespace character
73
A logical line starts with non-whitespace text. A
74
line that starts with whitespace continues a logi-
79
A logical line starts with non-whitespace text. A
80
line that starts with whitespace continues a logi-
77
Each pattern is a POSIX regular expression enclosed by a
83
Each pattern is a POSIX regular expression enclosed by a
78
84
pair of delimiters. The regular expression syntax is docu-
79
mented in <b>re_format</b>(7) with 4.4BSD, in <b>regex</b>(5) with
85
mented in <b>re_format</b>(7) with 4.4BSD, in <b>regex</b>(5) with
80
86
Solaris, and in <b>regex</b>(7) with Linux. Other systems may use
81
87
other document names.
83
The expression delimiter can be any character, except
89
The expression delimiter can be any character, except
84
90
whitespace or characters that have special meaning (tradi-
85
tionally the forward slash is used). The regular expres-
91
tionally the forward slash is used). The regular expres-
86
92
sion can contain whitespace.
88
94
By default, matching is case-insensitive, and newlines are
89
not treated as special characters. The behavior is con-
90
trolled by flags, which are toggled by appending one or
95
not treated as special characters. The behavior is con-
96
trolled by flags, which are toggled by appending one or
91
97
more of the following characters after the pattern:
93
99
<b>i</b> (default: on)
94
Toggles the case sensitivity flag. By default,
100
Toggles the case sensitivity flag. By default,
95
101
matching is case insensitive.
97
103
<b>x</b> (default: on)
98
Toggles the extended expression syntax flag. By
99
default, support for extended expression syntax is
104
Toggles the extended expression syntax flag. By
105
default, support for extended expression syntax is
102
108
<b>m</b> (default: off)
103
Toggle the multi-line mode flag. When this flag is
104
on, the <b>^</b> and <b>$</b> metacharacters match immediately
105
after and immediately before a newline character,
106
respectively, in addition to matching at the start
109
Toggle the multi-line mode flag. When this flag is
110
on, the <b>^</b> and <b>$</b> metacharacters match immediately
111
after and immediately before a newline character,
112
respectively, in addition to matching at the start
107
113
and end of the input string.
109
115
<b>TABLE SEARCH ORDER</b>
110
Patterns are applied in the order as specified in the ta-
111
ble, until a pattern is found that matches the input
116
Patterns are applied in the order as specified in the ta-
117
ble, until a pattern is found that matches the input
114
Each pattern is applied to the entire input string.
115
Depending on the application, that string is an entire
120
Each pattern is applied to the entire input string.
121
Depending on the application, that string is an entire
116
122
client hostname, an entire client IP address, or an entire
117
mail address. Thus, no parent domain or parent network
118
search is done, and <i>user@domain</i> mail addresses are not
119
broken up into their <i>user</i> and <i>domain</i> constituent parts,
123
mail address. Thus, no parent domain or parent network
124
search is done, and <i>user@domain</i> mail addresses are not
125
broken up into their <i>user</i> and <i>domain</i> constituent parts,
120
126
nor is <i>user+foo</i> broken up into <i>user</i> and <i>foo</i>.
122
128
<b>TEXT SUBSTITUTION</b>
123
Substitution of substrings from the matched expression
124
into the result string is possible using $1, $2, etc.;
129
Substitution of substrings from the matched expression
130
into the result string is possible using $1, $2, etc.;
125
131
specify $$ to produce a $ character as output. The macros
126
in the result string may need to be written as ${n} or
132
in the result string may need to be written as ${n} or
127
133
$(n) if they aren't followed by whitespace.
129
Note: since negated patterns (those preceded by <b>!</b>) return
135
Note: since negated patterns (those preceded by <b>!</b>) return
130
136
a result when the expression does not match, substitutions
131
137
are not available for negated patterns.