On 6/27/06, Michael Daly <[EMAIL PROTECTED]> wrote:
On 27 Jun 2006 at 16:45, Joshua Slive wrote:
> On 6/26/06, Michael Daly <[EMAIL PROTECTED]> wrote:
> > I'm trying to catch camelCase names. The mod_rewrite log file
> > shows:
> >
> > RewriteCond: input='^/cgi-sys/cgiwrap/guille/wiki.pl/fooBar'
> > pattern='^/cgi-sys/cgiwrap/guille/wiki.pl/(.*)([a-z])([A-Z])(.*)' =>
> > not-matched
> >
> > Testing at www.regular-expressions.info/javascriptexample.html
> > gives:
> > %1=/cgi-sys/cgiwrap/guille/wiki.pl/fo
> > %2=0
> > %3=B
> > %4=ar
[...]
> Can you show us the exact set of RewriteCond/RewriteRules you are
> using?
The following will:
1) define lc as a lower case function
2) check for desired URI and replace "$" with "/query string"
3) change first upper case letter to lower case (e.g. CamelCase to
camelCase)
Up to this point, the log file shows everything working as expected.
4) check for next camel case and change to lower case with preceding
underscore - (e.g. camelCase to camel_case )
This fails with log file output as shown in previous message.
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^/cgi-sys/cgiwrap/guille/wiki.pl$ [NC]
RewriteRule .* /cgi-sys/cgiwrap/guille/wiki.pl/%{QUERY_STRING} [NS]
RewriteCond $1 ^/cgi-sys/cgiwrap/guille/wiki.pl/([A-Z])(.*)
RewriteRule ^(.*)$ ^/cgi-sys/cgiwrap/guille/wiki.pl/${lc:%1}%2 [NS]
RewriteCond $1 ^/cgi-sys/cgiwrap/guille/wiki.pl/(.*)([a-z])([A-Z])(.*)
RewriteRule ^(.*)$ ^/cgi-sys/cgiwrap/guille/wiki.pl/%1%2_${lc:%3}%4 [N,NS]
Can you verify if you get the same result if you put that regex on its
own in a RewriteRule (rather than in a big chain)?
There is some possibility that this is a PCRE issue (the regex engine
used by apache) with greedy processing. (It may not be backtracking
to match the third group after it already matches the first and
second.) If so, you could probably work around it by using
...wiki.pl/([a-z]+)([A-Z])(.*)
in your regex (and obviously changing your substitution variables to
match). And as a bonus, that regex should be substantially faster
since it doesn't require all the back-tracking to find a match.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]