Re: Exim Filter

Pàgina inicial
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
A: Tim Patterson
CC: exim-users
Assumpte: Re: Exim Filter
On Tue, 14 Oct 1997, Tim Patterson wrote:

> It may be a BSDI 2.1 or Exim 1.62. or a Tim issue. I am a
> beginner+ to pattern matching.


"Mastering Regular Expressions" by Jeffrey E.F. Friedl, O'Reilly, 1997,
ISBN 1-56592-257-3.

The next version of Exim will support full Perl 5 regular expressions.

> From: 1234@???
>
> True $h_from: contains global
> True $h_from: matches global
> False $h_from: matches 'global'
> False $h_from: contains 'global'


Single quotes are not special in filter file arguments.

> False $h_from: matches \b[0-9]+@.*\.com\b


All items in filter files undergo string expansion before further
processing. Unfortunately, the \ character does duty as a quoting
character for string expansion as well as for regular expressions. You
need to use \\b[0-9]+@.*\\.com\\b here.

> Error $h_from: matches ^[0-9]+@.*\.com$


$ introduces special processing during string expansion. Consequently
you need to escape it with a \. Thus this one should be ^[0-9]+@.*\\.com\$


I realize that this is all rather unfortunate and tricky to explain. I
have a note to try to be clearer in the next edition of the manual,
where the chapter on regular expressions will have to be totally
rewritten anyway.

The underlying cause is the desire not to use up too many different
special characters for quoting purposes. That's why I chose the
"standard" backslash for quoting both in quoted strings and in string
expansions. If you have something that is (a) in double quotes (b)
passed through string expansion and (c) treated as a regular expression,
you have to be prepared for 3 levels of interpretation of \. Thus, if
you put your regular expressions in doublequotes in a filter, you get
things like

if $h_from matches "\\\\b[0-9]+@.*\\\\.com\\\\b"

which is a severe case of backslashitis...

-- 
Philip Hazel                   University Computing Service,
ph10@???             New Museums Site, Cambridge CB2 3QG,
P.Hazel@???          England.  Phone: +44 1223 334714



--
* This is sent by the exim-users mailing list.  To unsubscribe send a
    mail with subject "unsubscribe" to exim-users-request@???
* Exim information can be found at http://www.exim.org/