httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: Expression Parser: search and replace with s/PATTERN/REPLACEMENT/FLAGS
Date Sun, 04 Oct 2015 10:51:13 GMT
On 04 Oct 2015, at 12:46 PM, Rainer Jung <rainer.jung@kippdata.de> wrote:

>> But it must not be too complicated. We don't want an unreadable mess
>> like the sh/bash string manipulation functions.

+1.

> Yes, I agree. When starting to think closer, I noticed that the string mode currently
only supports a syntax that is pretty different from the boolean mode and is much more limited.
In that mode everything is a string except it is marked via %{XXX}, in which case XXX is a
variable name, except XXX is AAA:BBB in which case it is AAA("BBB").
> 
> So AFAIK we don't support functions with more than one argument in string mode and my
naive idea of using "STRING =~ s/PATTERN/REPLACEMENT/FLAGS" runs into the problem, that we
currently don't support operators like "=~" etc. in string mode.
> 
> So I wonder whether it would be useful to allow for a more general mode which would depending
on operators or functions handle the argument and result as strings or booleans using auto
conversion between them where needed. Of course in that mode verbatim strings would need proper
quoting (unlike pure string mode in which everything by default is a verbatim string). We
could then even support
> 
>    BOOLEXPR ? STRINGEXPR1 : STRINGEXPR 2
> 
> For compatibility that generalized mode would probably need a mode differentiator syntax
for compatibility reasons in 2.4 but could be the default mode in trunk. Something like your
"%!" prefix.

How about a regex function?

The single argument could be “s/PATTERN/REPLACEMENT/FLAGS”.

Regards,
Graham
—


Mime
View raw message