Re: [exim] Exim filter / Regexp weirdness

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Tony Finch
Dátum:  
Címzett: Sander Smeenk
CC: exim-users
Tárgy: Re: [exim] Exim filter / Regexp weirdness
On Mon, 26 Sep 2005, Sander Smeenk wrote:
>
> And they end up in the wrong mailbox because the first @ matches the @
> in front of 'bar', the [^@]+ matches 'bar.tld, adse', and \.(fi|se)
> matches the 'nse' part of 'adsense'. So, how can I force a literal . ?
> As writing \. doesn't help and \\. doesn't work either.


Read the filter documentation, which says:


Care must be taken if you need a backslash in a regular expression, because
backslashes are interpreted as escape characters both by the string
expansion code and by Exim's normal processing of strings in quotes. For
example, if you want to test the sender address for a domain ending in
".com" the regular expression is

\.com$

The backslash and dollar sign in that expression have to be escaped when
used in a filter command, as otherwise they would be interpreted by the
expansion code. Thus what you actually write is

if $sender_address matches \\.com\$

An alternative way of handling this is to make use of the "\N" expansion
flag for suppressing expansion:

if $sender_address matches \N\.com$\N

Everything between the two occurrences of "\N" is copied without change by
the string expander (and in fact you do not need the final one, because it
is at the end of the string).

If the regular expression is given in quotes (mandatory only if it contains
white space) you have to write either

if $sender_address matches "\\\\.com\\$"

or

if $sender_address matches "\\N\\.com$\\N"


Tony.
--
<fanf@???> <dot@???> http://dotat.at/ ${sg{\N${sg{\
N\}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}\
\N}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}