Re: [Exim] Exim 4.1: rewriting question (changing "From:" he…

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Ralf G. R. Bergs
CC: exim-users@exim.org
Subject: Re: [Exim] Exim 4.1: rewriting question (changing "From:" header depending on recipient)
On Wed, 14 Aug 2002, Ralf G. R. Bergs wrote:

> rabe@???     \
>   "${if and {
>           {def:h_To:}
>           {match
>              {$h_To:}
>              {\\N^(\"someone@???\" )?<?someone@???>?$\\N}
>           }
>         } {rabe-lkt} fail
>      }" fFrQ

>
> I've broken the line to make it more readable, I hope it's still obvious how
> the expression looks like.
>
> The pattern recognizes addresses like the following:
>
>     "someone@???" <someone@???>
>     <someone@???>
>     someone@???

>
> Is this, in your eyes, the optimal way of writing this, or can you give me
> additional hints about how to further improve it?


1. You don't really need the def:h_To: condition, because if there is no
To: header, $h_To: expands to an empty string.

2. Your regex will also match

      "someone@???" someone@???
      <someone@???
      someone@???>


but as those are illegal (and should never happen), it doesn't really matter.

3. Perhaps more imporantly, your regex will also match

      someone@somewhere+org


etc. For tidiness, it is best to escape the dots.

4. Do you care about multiple spaces between the two parts?

5. A slightly more efficient regex would use (?:...) instead of (...) to
save some work, but it will only be very slightly more efficient.






--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.