Re: [exim] How to spell a regexp with a space in an Exim fil…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Ian Zimmerman
Dátum:  
Címzett: Exim Mailinglist
Tárgy: Re: [exim] How to spell a regexp with a space in an Exim filter?
> On 19/01/2019 00:49, Ian Zimmerman via Exim-users wrote:
> > Three possibilities, I don't know which one would work:
> >
> > $h_x-foo: matches \N"foo[.]? bar$"\N
> >
> > $h_x-foo: matches "\Nfoo[.]? bar$\N"
> >
> > $h_x-foo: matches \Nfoo[.]? bar$\N
> >
> > The documentation, alas, doesn't help.
> >


Ok, maybe this wasn't very clear. I'll try again.

Let's say I am trying to match any of these possibilities in the header,
with _one_ match condition:


X-Loosely-Foobar: Foobar

or

X-Loosely-Foobar: Foo bar

or

X-Loosely-Foobar: Foo Bar


I know all albout regexes, and at this point I'll even say immodestly
that I understand the Exim configuration file quite well. However, this
isn't in the configuration file proper, but in a filter; and even aside
from that, the crucial point _how quoting and \N interact_ is just not
addressed in the spec.

I tried all of the following. The first two are syntactically invalid;
that tells me \N doesn't protect spaces like quotes do, and quotes
_inside_ \N don't do their normal job of protecting spaces:

$h_x-loosely-foobar: matches \NFoo[ ]*[bB]ar\N ** SYNTAX ERROR **

$h_x-loosely-foobar: matches \N"Foo[ ]*[bB]ar"\N ** SYNTAX ERROR **

And the third passes a syntax check, but doesn't match when it should.
That tells me \N _inside quotes_ doesn't do it's normal job of
protecting regex syntax, and is probably interpreted as just plain N:

$h_x-loosely-foobar: matches "\NFoo[ ]*[bB]ar\N" ** NO MATCH **

So then, how can I spell this match (rather simple one IMO) and avoid
soul-crushing backslashitis?

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.