Re: [exim] Regex Help?

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Ian Eiloart
Dátum:  
Címzett: Marc Perkel, Exim users mailing list
Tárgy: Re: [exim] Regex Help?


--On 29 June 2007 10:53:40 -0700 Marc Perkel <marc@???> wrote:

> Need some regex help. What I want to do is grab the domain part of a
> sender host name where it is a one level domain.
>
> xxx.ftp.perkel.com -> perkel.com
>
> And a separate one that works with two level domains:


> xxx.ftp.perkel.co.uk -> perkel.co.uk
>
> Here's a crude poice of code I've been using. Need something like this.
>
>     set acl_c_sender_host_domain =
> ${sg{$sender_host_name}{(\N^.*\.)(.*\.(com|net|org|edu|biz|name|mil|gov))
> $\N}{\$2}}


Try these, which are untested:


${sg{$sender_host_name}{(\N^.*\.)([^\.]+\.[^\.]+$) $\N}{\$2}}

and (for two-level)
${sg{$sender_host_name}{(\N^.*\.)([^\.]+\.[^\.]+\.[^\.]+$) $\N}{\$2}}

NB: the "$" matches the end of the string. "[^\.]+" should match a string
of non-dots.

This might be a bit more efficient:

${sg{$sender_host_name}\N{.*\.([^\.]+(\.[^\.]+)2$) $\N}{\$1}}

Which should match, anything followed by a dot, (followed by a non-dot
string, (followed by a dot followed by a non-dot string ) twice) at the end
of the line.

And you could go for 3-level by replacing "2" with "3", etc. So, you could
even provide that number parametrically.


> Thanks in advance.




--
Ian Eiloart
IT Services, University of Sussex
x3148