RegEx, matching if not containing...

Posted by Tommy Jakobsen on Stack Overflow See other posts from Stack Overflow or by Tommy Jakobsen
Published on 2010-03-17T09:21:53Z Indexed on 2010/03/17 9:31 UTC
Read the original article Hit count: 328

Filed under:

I've been trying to figure out how to write this regular expression. It is to be used for ISAPI_Rewrite, a module for IIS 6, for doing URL rewriting.

I want the url /hg/<parameter> to be mathed, so it can be rewrited to /hg/hgwebdir.cgi/<parameter>.

I've matched it using ^/hg/(.*).

My problem is, if the URL /hg/hgwebdir.cgi/<parameter> is used, the regex should NOT match. Using the above regex with this URL, will rewrite to /hg/hgwebdig.cgi/hgwebdig.cgi/<parameter> which is not correct.

Can you help me create the matching pattern?

© Stack Overflow or respective owner

Related posts about regex