httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross Heritage <rherit...@Lastminute.com>
Subject Re: Regex Help with Mod Rewrite
Date Tue, 21 Aug 2007 16:34:38 GMT
Hi Soumya,

Yep, for the future you probably want the user support list (
http://httpd.apache.org/lists.html#http-users).

However, to be helpful I think the answers to your questions would be

1) Apache 1.3 uses POSIX based regular expressions, and apache 2.x uses the
PCRE library, so they're perl compatible.

2)
RewriteCond %{QUERY_STRING}
(^|&|;)Operation=(((rain|spain|plain),)*(rain|spain|plain))($|&|;)
RewriteRule . - [E=OPERATION:%2]

There are lots of ways to optimise the above, but I've kept it to something
relatively simple for easy reading...
If you wanted anything more complicated than that in a single rule, I'd
suggest looking at writing your own internal map function. This list could
help you with that.

HTH,

Ross Heritage.


On 21/8/07 17:04, "Soumya Sanyal" <soumya.sanyal@gmail.com> wrote:

> Hello,
>  This might not be the most appropriate forum to field this question - but
> I'm having serious issues with the formulation of a regex for Mod Rewrite. I
> actually have a couple of questions to ask :
> 
> 1> What is particular flavor of the regex engine being used by Mod Rewrite -
> there are ever so slight variations in the different regex engines, e.g.
> linux grep vs perl grep etc.
> 2> I'm having trouble formulating a good compact regex to represent the
> following problem :
> 
> I want my RewriteCond to be conditioned on the %{QUERY_STRING} to contain
> only the powerset of a group of words e.g.
> 
> Hence if my set is say {rain,spain,plain}
> 
> The RewriteCond should say yes to the following :
> http://foo.bar.com/?Operation=rain,spain
> http://foo.bar.com/?Operation=plain,rain,rain
> http://foo.bar.com/?Operation=plain,rain,spain
> 
> But not :
> http://foo.bar.com/?Operation=rain,spain,mainly
> 
> Help please ?

Mime
View raw message