lookaround in mod_substitute pattern

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

 



Hi list!

I was testing mod_substitute and lookaheads. I tested with the simple setup below (a simple string in an index.html, and a .htaccess file), and the lookahead yields expected result, the negative lookahead and the lookbehind have no effect.
The negative lookbehind has a behaviour that I do not understand.

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 ?

And as a bonus question, why is the last test ( Substitute "s/a(?<!m)/Q/" ) changing all letters to 'Q' instead of not changing the string like the 2nd and the 3rd test ?

Thanks for sharing your insights!
Zimmi


SETUP
index.html :
Llamas are my favorite animals.

.htaccess :
AddOutputFilterByType SUBSTITUTE text/html

# Original string inside an index.html :
# Llamas are my favorite animals.

# 1. Lookahead, OK
# Expected : word 'favorite' changed:
# Llamas are my f4vorite animals.
Substitute "s/a(?=v)/4/"

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

# 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/"


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