views:

30

answers:

3

I've recently inherited a site created in Dreamweaver where all URLs use the 'up one level' notation e.g. "../products/" and I would like to do a global find and replace with root path e.g. "/products/".

What's the regular expression I need to use in the Visual Studio Find & Replace Dialog to replace the following matches:

"../../../products" with "/products/"
"../../products/" with "/products/"
"../news" with "/news/"
"../*" with "/*"

All the URLs are relative to the root so I think I just need to replace any number of matched '../' with '/'

+1  A: 

Replace the following

(\.\./)+

with a single /

(Backup the project first ;) )

Jordan
+1  A: 

It's probably easiest to first replace (\.\./)+ with /.

Then check if your paths ends in a /, and add it if necessary.

Tim Pietzcker
+1  A: 

Try this :

(\.\./)+.+

Which converts to ../ repeated n times, followed by anything repeated n times

c0mrade