Appendix B. Regular Expressions

Regular expression support in Exim is provided by the PCRE library, which implements regular expressions whose syntax and semantics are the same as those in Perl.[206] The description here is taken from the PCRE documentation, and is intended as reference material. For an introduction to regular expressions, see Mastering Regular Expressions by Jeffrey Friedl (O’Reilly).

When you use a regular expression in an Exim configuration, you have to be a little careful about backslash, dollar, and brace characters, which quite often appear in regular expressions, because these characters are also interpreted specially by Exim. Backslash is special inside quoted strings, and all four characters are special in a string that is expanded. One way of setting up such configuration items is as follows:

  • First of all, create your regular expression according to the description in this appendix. In other words, find the character string that you ultimately want to pass to the regular expression matcher.

  • If the Exim option you are setting is one that is expanded, go through your expression and insert a backslash before every backslash, dollar, and brace character.

  • If the Exim option is a string inside double quotes, go through the expression again, inserting a backslash before every backslash.

If you are using Exim Version 3.14 or later, you do not need to use double quotes unless you specifically need to use escape sequences in the string. For example, suppose ...

Get Exim: The Mail Transfer Agent now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.