Exim Filter Specification section 6

Previous Next Contents (Exim Filter Specification)

## 6. String expansion

Most data values are expanded before use. Expansion consists of replacing substrings beginning with `$` with other text. The full expansion facilities available in Exim are extensive. If you want to know everything that Exim can do with strings, you should consult the chapter on string expansion in the Exim documentation.

In filter files, by far the most common use of string expansion is the substitution of the contents of a variable. For example, the substring

      $reply_address

is replaced by the address to which replies to the message should be sent. If such a variable name is followed by a letter or digit or underscore, it must be enclosed in curly brackets (braces), for example,

      ${reply_address}

If a `$` character is actually required in an expanded string, it must be escaped with a backslash, and because backslash is also an escape character in quoted input strings, it must be doubled in that case. The following two examples illustrate two different ways of testing for a `$` character in a message:

      if $message_body contains \$ then ...
      if $message_body contains "\\$" then ...

You can prevent part of a string from being expanded by enclosing it between two occurrences of `\N`. For example,

      if $message_body contains \N$$$$\N then ...

tests for a run of four dollar characters.

Previous Next Contents (Exim Filter Specification)