httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject Re: [users@httpd] lookaround in mod_substitute pattern
Date Fri, 10 Jul 2015 14:59:03 GMT
Hi Zimmi,

On Fri, Jul 10, 2015 at 1:26 PM, Zimmi <zimmi73@gmail.com> wrote:
>
> Are only lookahead (?=foo) supported in mod_substitute, and not the other
> (negative lookahead, lookbehind and negative lookbehind) ?
> Other syntax or did I miss something ?

A lookbehind assertion needs its subject to be placed *after* it, so
eg. "a" preceded by "m" is "(?<=m)a".

So in your examples:

>
> # 2. Lookbehind, not OK : nothing happens
> # Expected : word 'animals' changed:
> # Llamas are my favorite animAls.
> Substitute "s/a(?<=m)/A/"

=> Substitute "s/(?<=m)a/A/"

>
> # 3. Negative lookahead, not OK : nothing happens:
> # Expected : all remaining 'a' changed to '&' except last one in word
> 'animals':
> # Ll&m&s &re my f4vorite &nimals.
> Substitute "s/a(?!l)/&/"

=> Substitute "s/a(?!\l)/&/"
(The pipe has special meaning otherwise, but I'm not sure about your
goal here...).

>
> # 4. Negative lookbehind, not OK : changes all remaining occurrences of 'a'
> to 'Q' ? Why ?
> # Expected : all remaining 'a' changed to 'Q' except last 'a' in word
> 'animals'
> #            and first 'a' in 'Llamas' if not changed by rules before.
> Substitute "s/a(?<!m)/Q/"

=> Substitute "s/(?<!m)a/Q/"


Regards,
Yann.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message