Page 1 of 1

Match line but replace only part?

Posted: Fri May 26, 2006 9:23 am
by Ecwfrk
I'm moving and cleaning up a website (about 40k pages) I took over maintence of that has several problems. Some people on a forum recommended I check out text pipe for some of the things I needed to do. So far many of the problems I have appear to be correctable with text pipe, but I don't see how to do one of the really major cleanup tasks I have.

The site has tons of internal page links that currently appear like:
../ ... x.htm#e955
../ ... x.htm#e968
../ ... .htm#e1425

the ../ and index.htm part of the URLs is constant but the rest is variable and there's several thousand different variations of the code that falls between them. What I want to do is drop everything but the /####/index.htm#xxxx to make simple relative links. So the examples above would eventually become something (I can easily adjust the paths and such after the main URL cleanup is done) like:


But I don't see a way for text pipe to do it. I can get it to match the full URLs easily enough with
../[ longest 1 to 40 letters or digits or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|> ]/[ longest 1 to 4 digits ]/index.htm[ longest 1 to 5 digits or letters or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|> ]
But I don't see any way to get it to remove the preceeding code and leave the part I want to keep nor anyway to match the offending text and just remove it without the part I want to keep.

Is it possible to to do this with Text Pipe?

Posted: Mon May 29, 2006 1:15 pm
by DataMystic Support
You need to use the EasyPattern capture() function for the bits you want to keep, then use variables $1.. in the replacement expression:

../[ longest 1 to 40 letters or digits or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|> ]/[ capture(longest 1 to 4 digits) ]/index.htm[ capture(longest 1 to 5 digits or letters or <!"#$%&'()*+,-./\:;=?@[]^_`{}~|>) ]

Replace with