httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <>
Subject LocationMatch (and friends) and back references
Date Thu, 26 Dec 2013 07:43:14 GMT
Hi all,

It seems it is currently not possible to make reference to backreferences in regexes:

<LocationMatch ~ ^/(foo|bar)/baz>
  Something ${1}

One of the tricky things to overcome to make this possible is that multiple LocationMatch'es
might match, which makes the traditional ${1} pattern tricky to implement internally, as ${1}
might be shadowed by another LocationMatch. As a possible solution to this, we could pass
explicit variable names after the regex which are then populated into the subprocess environment
and can be referenced elsewhere:

<LocationMatch ~ ^/(foo|bar)/baz/(.*) MYPREFIX MYFILE>
  Something ${MATCH_MYPREFIX}
  SomethingElse ${MATCH_MYFILE}

Naming the backreferences explicitly has the advantageous side effect that we know how many
of them there are (or we care about) and can pass or not pass the correct sized array to ap_regexec()
as needed, meaning that supporting backreferences needs no performance penalty for people
who don't use them.

Obviously the making the subprocess environment available to directives is a separate issue.



View raw message