[Toolserver-l] change of regular expression behaviour in rewrite scripts

seth email_metawiki_138 at wg-karlsruhe.de
Thu Aug 20 08:29:12 UTC 2009


Hi!

On Wed, August 19, 2009 22:55, River Tarnell wrote:
> after the web server change on Wednesday, we noticed the following
> behaviour of regexp matching in rewrite scripts: when using a construct
> like "(a|b|)", the regexp will *not* match the empty string.  as a
> workaround, you can write "(a|b)?".  if you do not use this construct
> in your rewrite.script, this does not affect you.

I'm not very experienced in rewrite-regexp. But in perl (and php's pcre,
...) this would not be a good work-around, because the capture buffer
would sometimes be created and sometimes not.

If one does not need capture buffers, he should write
  (?:a|b)?
If one needs capture buffers but can't use (a|b|), he should use
  ((?:a|b)?)
This will in any case make it possible to use a corresponding backreference.

All this holds for perl, I'm not sure whether this is releveant for
rewrite-regexp. If it does not, you may just call me clever shit, I guess.
:-)

prosit
seth




More information about the Toolserver-l mailing list