httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zimmi <zimm...@gmail.com>
Subject [users@httpd] lookaround in mod_substitute pattern
Date Fri, 10 Jul 2015 11:26:07 GMT
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@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message