Re: [exim] Extracting the last field

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Todd Lyons
Ημερομηνία:  
Προς: soumya tr
Υ/ο: exim-users@exim.org
Αντικείμενο: Re: [exim] Extracting the last field
On Wed, Jun 26, 2013 at 10:13 AM, soumya tr <soumya.324@???> wrote:
> Hi,
>
> Is it possible to extract the last field using extract in exim?
> Suppose the input is:
> "abc@???" <ghi@???>
>
> I need to extract the last field when delimiter is '@'.
> Using ${extract {3}{@}{"abc@???" <ghi@???>}}, I can obtain jkl.com>
> . But i needed a generic solution. As incase there are >3 @ , then the
> obtained output will not be the expected one. How can I achieve this?


Phil Pennock provided a fantastic solution to that a while back:

To get the last:
${reduce{${addresses:$h_from:}}{}{$item}}
To get the first:
${reduce{${addresses:$h_from:}}{}{${if eq{$value}{}{$item}{$value}}}}

http://www.exim.org/lurker/message/20110310.173811.9608d368.en.html

...Todd
--
The total budget at all receivers for solving senders' problems is $0.
If you want them to accept your mail and manage it the way you want,
send it the way the spec says to. --John Levine