General-Purpose Mail Filter
A back reference is a sequence ‘\d’, where d
is a decimal number. It refers to the dth parenthesized
subexpression in the last
matches statement12. Any back reference occurring within a
double-quoted string is replaced with the value of the corresponding
subexpression. For example:
if $f matches '.*@\(.*\)\.gnu\.org\.ua' set host \1 fi
If the value of
f macro is ‘firstname.lastname@example.org’, the
above code will assign the string ‘unza’ to the variable
Notice, that each occurrence of
matches will reset the table
of back references, so try to use them as early as possible. The
following example illustrates a common error, when the back
reference is used after the reference table has been reused by another
# Wrong! if $f matches '.*@\(.*\)\.gnu\.org\.ua' if $f matches 'some.*' set host \1 fi fi
This will produce the following run time error:
mailfromd: RUNTIME ERROR near file.mf:3: Invalid back-reference number
because the inner match (‘some.*’) does not have any parenthesized subexpressions.
See Special comparisons, for more information about
The subexpressions are numbered by the positions of their opening parentheses, left to right.
This document was generated on January 3, 2019 using makeinfo.Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.