You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by hernan gonzalez <hg...@gmail.com> on 2011/04/08 16:03:31 UTC

sample regex patterns are mildly confusing

Issue commented here

   http://stackoverflow.com/questions/5587148/regex-patterns-in-apache-rewritecond-and-friends-full-or-partial-match

It feels redundant and confusing to me to write (a single example
among many others in the docs) :

             RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla.*

when the .* is really not need - confusing, because it might lead to
believe that Apache is trying a full match, i.e. matching the full
string.

It would be neater and cleaner to write instead

              RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla

Regards

------------------------------------------------------------------------------
H. Gonzalez

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Re: sample regex patterns are mildly confusing

Posted by Rich Bowen <rb...@rcbowen.com>.
I've fixed the case that I think you're referring to. Please let me know if there are others. Folks tend to throw .* into regular expressions frequently when it's not necessary.


On Apr 8, 2011, at 10:03 AM, hernan gonzalez wrote:

> Issue commented here
> 
>   http://stackoverflow.com/questions/5587148/regex-patterns-in-apache-rewritecond-and-friends-full-or-partial-match
> 
> It feels redundant and confusing to me to write (a single example
> among many others in the docs) :
> 
>             RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla.*
> 
> when the .* is really not need - confusing, because it might lead to
> believe that Apache is trying a full match, i.e. matching the full
> string.
> 
> It would be neater and cleaner to write instead
> 
>              RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla
> 
> Regards
> 
> ------------------------------------------------------------------------------
> H. Gonzalez
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
> For additional commands, e-mail: docs-help@httpd.apache.org
> 

--
Rich Bowen
rbowen@rcbowen.com
rbowen@apache.org
PGP Key ID CC78C893





---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org