Re: lookaround in mod_substitute pattern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Zimmi,

On Fri, Jul 10, 2015 at 1:26 PM, Zimmi <zimmi73@xxxxxxxxx> 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@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux