Macro needed to replace all instances of any text that is pa

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
asapReps
Posts: 2
Joined: Sun Mar 21, 2010 4:29 pm
Contact:

Macro needed to replace all instances of any text that is pa

Post by asapReps »

I am looking for a find/replace macro that will find all instances of any account "name" of an email address used for a fixed domain name and remove all instances found in a text file.

For example, xyz.com is the fixed domain name that is found in a text file. I want to find all instances of any account name that is associated with xyz.com and remove/replace them in the file. I also want to remove/replace any other instances of the name xyz.com. I want to run the same macro on each file I open.

The account name of an xyz.com email address will change from email to email, so I can't key on certain "words". One email address may be abcd-eFd@xyz.com in one file, Abcd@xyz.com in another file, 123D_df6hsg2@xyz.com in another file, dr.koBsd.Sq2@xyz.com in another file, and so on ...


I need to automatically find the account name that comes before the "@" and then automatically use that output as input to find ALL instances of it in the same file, and then replace all instances with something generic like "z".

The account name portion of the email address may also be found in other places in the file, prepended (or even appended) to other characters, or it may be by itself.

So if an email comes to abcd-eFd@xyz.com, then I want to find ALL instances of "abcd-eFd" in the file and replace them with "z".


The abcd-eFd characters that are part of the abcd-eFd@xyz.com email address might be found in the following lines of the file:


Return-Path: <abcd-eFd76S2l@mymymy.com>
From: "Dufus" <abcd-eFd76S2l@mymymy.com>
To: abcd-eFd@xyz.com
Message-ID: <0B121-87654321-12345678-11.11-abcd-eFd#xyz.com@WQ2FVZ-ZZ>

Greetingz abcd-eFd today
Hi there abcd-eFd!

(mailto:abcd-eFd@zyx.net)
<a href=3D"mailto:abcd-eFd@xyz.com" style=3D"text-decoration: none; font-size: 14px; color:#860000; font-weight:normal;text-shadow:1px 1px #FFF;">abcd-eFd@xyz.com</a>
<td width=3D"314" height=3D"20">This was sent to <span style=3D"tex=
t-decoration:none; color:#767575;">abcd-eFd@xyz.com</span>




I want the file contents to be changed to:



Return-Path: <z76S2l@mymymy.com>
From: "Dufus" <z76S2l@mymymy.com>
To: z
Message-ID: <0B121-87654321-12345678-11.11-z@WQ2FVZ-ZZ>

Greetingz z today
Hi there z!

(mailto:z@zyx.net)
<a href=3D"mailto:z" style=3D"text-decoration: none; font-size: 14px; color:#860000; font-weight:normal;text-shadow:1px 1px #FFF;">z</a>
<td width=3D"314" height=3D"20">This was sent to <span style=3D"tex=
t-decoration:none; color:#767575;">z</span>


Is there a single find/replace and/or regex macro that could be created that would accomplish this? I have been unsuccessful, so far... I have had to update my macro way to often to add different/new account names and then search for the specific string. Very inefficient...

I am currently using Textpad 5.4.2
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

You need a programming language.
(2[Bb]|[^2].|.[^Bb])

That is the question.
Post Reply