tags:

views:

48

answers:

1

I need help with a regular expression for use with UrlRewriting.Net. I have two URLs -

http://domain/SomeFolder/tracks/SomeFileName/

and

http://domain/SomeFolder/<could be anything>/SomeFileName/

For URL rewriting purposes I need to come up with one expression that will let me target specifically the URL with "tracks" in the middle of it. I need another expression to catch everything without "tracks" in it.

Before I had this constraint I was using ^~/SomeFolder/([^/]*)/SomeFileName/?$ and that worked as my catch-all. Now that I have this specific "tracks" folder, I can't use the catch all.

Make sense?

Many thanks for the help!

+2  A: 
^~/SomeFolder/(?!tracks/)([^/]*)/SomeFileName/?$

and

^~/SomeFolder/(tracks)/SomeFileName/?$
Ignacio Vazquez-Abrams
Fantastic - thanks!
Acoustic