Mailing List Archive

How to spell a regexp with a space in an Exim filter?
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.

--
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.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to spell a regexp with a space in an Exim filter? [ In reply to ]
> 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.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to spell a regexp with a space in an Exim filter? [ In reply to ]
On 19/01/2019 18:36, Ian Zimmerman via Exim-users wrote:
> 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

The docs give examples which appear to cover your needs:
quotes on the outside and you don't appear to need \N
(but you'd have to write it with doubled \ and within
the quotes, if you did need it eg. to manage $-signs).

I'm looking at


http://exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_filter_files.html

section 22. Perhaps you didn't find that?

--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to spell a regexp with a space in an Exim filter? [ In reply to ]
On 2019-01-19 19:20, Jeremy Harris wrote:

> The docs give examples which appear to cover your needs:
> quotes on the outside and you don't appear to need \N
> (but you'd have to write it with doubled \ and within
> the quotes, if you did need it eg. to manage $-signs).
>
> I'm looking at
>
> http://exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_filter_files.html
>
> section 22. Perhaps you didn't find that?

I had found that section, but those examples have no spaces in the
regex. And indeed my real pattern contains $, so that is part of the
problem. Meanwhile I found a workaround with character classes, like
this:

\NFoo[[:blank:]]*[bB]ar\N

(or any more perlish way of saying "blank").

Still, I think this aspect of the syntax is disappointing. I suggest a
new feature: a superquote (for example \Q) which has the powers of
_both_ \N and '"'.

Thanks for your help.

--
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.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to spell a regexp with a space in an Exim filter? [ In reply to ]
True, the examples did not contain any spaces. The text however said:

"If the regular expression is given in quotes (mandatory only if it
contains white space)"


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: How to spell a regexp with a space in an Exim filter? [ In reply to ]
On 2019-01-19 21:37, Jeremy Harris wrote:

> True, the examples did not contain any spaces. The text however said:
>
> "If the regular expression is given in quotes (mandatory only if it
> contains white space)"

Score: Jeremy 1, Ian 0 ... but the examples immediately following
certainly show what I term "soul-crushing backslashitis", so Jeremy 1,
Ian 1.

:-)

Really, at my age counting backslashes just won't do it. At all.

--
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.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/