Wonko the sane has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
Here is what I am trying to do.
The problem is I cannot use negative lookahead to do it.if ( m|/user/(?!prot/)| )
To do this, I have tried the following variations with no success.
The only one that I want to print "Allowed", (not to match) is the first one "/user/prot/".#!/usr/local/bin/perl5.6.0 -w use strict; while ( <DATA> ) { chomp; #if ( m|/user/(?!prot/)| ) # Works #if ( m|/user/[^p]?[^r]?[^o]?[^t]?[^/]?| ) #if ( m|/user/([^p]*?[^r]*?[^o]*?[^t]*?[^/]*?)?| ) #if ( m|/user/[^p]+?[^r]+?[^o]+?[^t]+?[^/]+?| ) #if ( m|/user/([^p]*[^r]*[^o]*[^t]*[^/]*)?| ) { print qq{Disallow!! [$_]\n}; } else { print qq{Allowed. [$_]\n}; } } __DATA__ /user/prot/ /user/protrusions/ /user/a/ /user/backups
OT: Why cant I use negative lookahead?
Actually because I am trying to make a regex for an Apache LocationMatch section,
to disable some settings for all directories inside a users site, except for one,
'/user/prot'.
The regex engine in Apache though does not have lookaround assertion ability :(.
Any help is much appreciated.<LocationMatch /user/(?!prot/) > <Limit GET> order allow,deny deny from all </Limit> AllowOverride None </LocationMatch>
Wonko
Back to
Seekers of Perl Wisdom