xref: /netbsd-src/external/ibm-public/postfix/dist/html/pcre_table.5.html (revision 37afb7eb6895c833050f8bfb1d1bb2f99f332539)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3<html> <head>
4<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
5<title> Postfix manual - pcre_table(5) </title>
6</head> <body> <pre>
7PCRE_TABLE(5)                                                    PCRE_TABLE(5)
8
9<b>NAME</b>
10       pcre_table - format of Postfix PCRE tables
11
12<b>SYNOPSIS</b>
13       <b>postmap -q "</b><i>string</i><b>" <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i>
14
15       <b>postmap -q - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
16
17<b>DESCRIPTION</b>
18       The  Postfix  mail  system  uses optional tables for address rewriting,
19       mail routing, or access control. These tables are usually in <b>dbm</b> or  <b>db</b>
20       format.
21
22       Alternatively,  lookup tables can be specified in Perl Compatible Regu-
23       lar Expression form. In this case, each input  is  compared  against  a
24       list  of  patterns.  When a match is found, the corresponding result is
25       returned and the search is terminated.
26
27       To find out what types of lookup tables your  Postfix  system  supports
28       use the "<b>postconf -m</b>" command.
29
30       To test lookup tables, use the "<b>postmap -q</b>" command as described in the
31       SYNOPSIS above.
32
33<b>COMPATIBILITY</b>
34       With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to  query  a
35       table that contains case sensitive patterns. Patterns are case insensi-
36       tive by default.
37
38<b>TABLE FORMAT</b>
39       The general form of a PCRE table is:
40
41       <b>/</b><i>pattern</i><b>/</b><i>flags result</i>
42              When <i>pattern</i> matches the input  string,  use  the  corresponding
43              <i>result</i> value.
44
45       <b>!/</b><i>pattern</i><b>/</b><i>flags result</i>
46              When  <i>pattern</i>  does  <b>not</b>  match the input string, use the corre-
47              sponding <i>result</i> value.
48
49       <b>if /</b><i>pattern</i><b>/</b><i>flags</i>
50
51       <b>endif</b>  Match the input string  against  the  patterns  between  <b>if</b>  and
52              <b>endif</b>,  if  and only if that same input string also matches <i>pat-</i>
53              <i>tern</i>. The <b>if</b>..<b>endif</b> can nest.
54
55              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
56
57              This feature is available in Postfix 2.1 and later.
58
59       <b>if !/</b><i>pattern</i><b>/</b><i>flags</i>
60
61       <b>endif</b>  Match the input string  against  the  patterns  between  <b>if</b>  and
62              <b>endif</b>, if and only if that same input string does <b>not</b> match <i>pat-</i>
63              <i>tern</i>. The <b>if</b>..<b>endif</b> can nest.
64
65              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
66
67              This feature is available in Postfix 2.1 and later.
68
69       blank lines and comments
70              Empty lines and whitespace-only lines are ignored, as are  lines
71              whose first non-whitespace character is a `#'.
72
73       multi-line text
74              A  logical  line  starts  with  non-whitespace text. A line that
75              starts with whitespace continues a logical line.
76
77       Each pattern is a perl-like regular expression. The  expression  delim-
78       iter  can  be  any  non-alphanumerical  character, except whitespace or
79       characters that have special meaning (traditionally the  forward  slash
80       is used).  The regular expression can contain whitespace.
81
82       By  default, matching is case-insensitive, and newlines are not treated
83       as special characters. The behavior is controlled by flags,  which  are
84       toggled  by appending one or more of the following characters after the
85       pattern:
86
87       <b>i</b> (default: on)
88              Toggles the case sensitivity flag. By default, matching is  case
89              insensitive.
90
91       <b>m</b> (default: off)
92              Toggles the PCRE_MULTILINE flag. When this flag is on, the <b>^</b> and
93              <b>$</b> metacharacters match immediately after and immediately  before
94              a  newline  character,  respectively, in addition to matching at
95              the start and end of the subject string.
96
97       <b>s</b> (default: on)
98              Toggles the PCRE_DOTALL flag.  When  this  flag  is  on,  the  <b>.</b>
99              metacharacter  matches  the newline character. With Postfix ver-
100              sions prior to 2.0, the flag is off by default, which is  incon-
101              venient for multi-line message header matching.
102
103       <b>x</b> (default: off)
104              Toggles the pcre extended flag. When this flag is on, whitespace
105              characters in the pattern (other than in a character class)  are
106              ignored.   To include a whitespace character as part of the pat-
107              tern, escape it with backslash.
108
109              Note: do not use <b>#</b><i>comment</i> after patterns.
110
111       <b>A</b> (default: off)
112              Toggles the PCRE_ANCHORED flag.  When this flag is on, the  pat-
113              tern  is  forced to be "anchored", that is, it is constrained to
114              match only at the start of the string which  is  being  searched
115              (the  "subject  string").  This  effect  can also be achieved by
116              appropriate constructs in the pattern itself.
117
118       <b>E</b> (default: off)
119              Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, a  <b>$</b>
120              metacharacter in the pattern matches only at the end of the sub-
121              ject string. Without this flag, a dollar  also  matches  immedi-
122              ately  before  the  final character if it is a newline character
123              (but not before any other  newline  characters).  This  flag  is
124              ignored if PCRE_MULTILINE flag is set.
125
126       <b>U</b> (default: off)
127              Toggles  the  ungreedy matching flag.  When this flag is on, the
128              pattern matching engine inverts the "greediness" of the  quanti-
129              fiers  so that they are not greedy by default, but become greedy
130              if followed by "?".  This flag can also set by a  (?U)  modifier
131              within the pattern.
132
133       <b>X</b> (default: off)
134              Toggles  the  PCRE_EXTRA  flag.  When this flag is on, any back-
135              slash in a pattern that is followed by a letter that has no spe-
136              cial  meaning causes an error, thus reserving these combinations
137              for future expansion.
138
139<b>SEARCH ORDER</b>
140       Patterns are applied in the order as specified in the  table,  until  a
141       pattern is found that matches the input string.
142
143       Each  pattern  is applied to the entire input string.  Depending on the
144       application, that string is an entire client hostname, an entire client
145       IP  address, or an entire mail address.  Thus, no parent domain or par-
146       ent network search is done, and <i>user@domain</i> mail addresses are not bro-
147       ken  up  into  their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i>
148       broken up into <i>user</i> and <i>foo</i>.
149
150<b>TEXT SUBSTITUTION</b>
151       Substitution of substrings (text that  matches  patterns  inside  "()")
152       from  the  matched  expression into the result string is requested with
153       $1, $2, etc.; specify $$ to produce  a  $  character  as  output.   The
154       macros  in  the result string may need to be written as ${n} or $(n) if
155       they aren't followed by whitespace.
156
157       Note: since negated patterns (those preceded by <b>!</b>) return a result when
158       the  expression  does  not  match,  substitutions are not available for
159       negated patterns.
160
161<b>EXAMPLE SMTPD ACCESS MAP</b>
162       # Protect your outgoing majordomo exploders
163       /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead
164
165       # Bounce friend@whatever, except when whatever is our domain (you would
166       # be better just bouncing all friend@ mail - this is just an example).
167       /^(friend@(?!my\.domain$).*)$/  550 Stick this in your pipe $1
168
169       # A multi-line entry. The text is sent as one line.
170       #
171       /^noddy@my\.domain$/
172        550 This user is a funny one. You really don't want to send mail to
173        them as it only makes their head spin.
174
175<b>EXAMPLE HEADER FILTER MAP</b>
176       /^Subject: make money fast/     REJECT
177       /^To: friend@public\.com/       REJECT
178
179<b>EXAMPLE BODY FILTER MAP</b>
180       # First skip over base 64 encoded text to save CPU cycles.
181       # Requires PCRE version 3.
182       ~^[[:alnum:]+/]{60,}$~          OK
183
184       # Put your own body patterns here.
185
186<b>SEE ALSO</b>
187       <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager
188       <a href="postconf.5.html">postconf(5)</a>, configuration parameters
189       <a href="regexp_table.5.html">regexp_table(5)</a>, format of POSIX regular expression tables
190
191<b>README FILES</b>
192       <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
193
194<b>AUTHOR(S)</b>
195       The PCRE table lookup code was originally written by:
196       Andrew McNamara
197       andrewm@connect.com.au
198       connect.com.au Pty. Ltd.
199       Level 3, 213 Miller St
200       North Sydney, NSW, Australia
201
202       Adopted and adapted by:
203       Wietse Venema
204       IBM T.J. Watson Research
205       P.O. Box 704
206       Yorktown Heights, NY 10598, USA
207
208                                                                 PCRE_TABLE(5)
209</pre> </body> </html>
210