Match line but replace only part?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

Post Reply
Posts: 1
Joined: Fri May 26, 2006 8:12 am

Match line but replace only part?

Post by Ecwfrk » Fri May 26, 2006 9:23 am

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?

User avatar
DataMystic Support
Site Admin
Posts: 2211
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia

Post by DataMystic Support » Mon May 29, 2006 1:15 pm

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


Simon Carter, - Insulin dose calculator for Type 1 diabetes - 250,000 free software downloads - send huge email attachments

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 8 guests