httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Poitrey <>
Subject Re: [users@httpd] Apache 1.3 mod_rewrite and regex backreferences
Date Thu, 22 Jan 2004 07:31:50 GMT
Brian Dessent <> writes:

> It's not  a bug.  Using backreferences  in the "search"  part of the
> regular expression is not  valid POSIX (extended) regular expression
> syntax.  Check  re_format(7).  A backslash  followed by a  number or
> letter is to match that number or letter, as if the backslash wasn't
> there.  You can  use backreferences only in the  "replace" part, not
> the "search" part. 
> What  you're referring  to is  only valid  in the  "Perl compatible"
> regular  expression flavor.   This is  not the  same as  egrep regex
> flavor.  Apache 1.3 uses egrep,  2.0 uses pcre, if I'm not mistaken.
> So you should be able to do this in 2.0 but not 1.3.

I can read the following in the POSIX regex documentation:

"[...] Finally, there  is one new type of atom,  a back reference: `\'
followed by  a non-zero decimal digit  d matches the  same sequence of
characters matched  by the dth  parenthesized subexpression (numbering
subexpressions by the positions  of their opening parentheses, left to
right),  so that  (e.g.)  `\([bc]\)\1'  matches `bb'  or `cc'  but not

And, if you test my regex with egrep, it works perfectly:

$ echo "/foo/foo"|egrep '^/(foo)/\1'

Finaly, I found in the  apache regex implementation source code (witch
isn't the  same code as the  egrep regex engine as  you said), special
things to handle  this kind of backreferences. In  can't bother why it
doesn't work anyway. 

Best regards,

 O  l  i  v  i  e  r    P  o  i  t  r  e  y

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message