Computing.Net > Forums > Programming > Find and replace

Find and replace

Reply to Message Icon

Original Message
Name: tobike
Date: August 22, 2006 at 09:09:21 Pacific
Subject: Find and replace
OS: W2k
CPU/Ram: 1gig
Model/Manufacturer: dell
Comment:

I have a big distribution list that I need to edit and remove some names that are with other departments

For example I need to remove all names that have zzz in them
Ex "zzzlastname, first name: acronym;"

I am unable to delete the whole name with the acronym.
I am using word with the find and replace option if I specify to find zzz and replace it with nothing of course it will remove the zzz but not the whole name
All names are separated by ;
SO using the wild card option I say <;zzz>;
but it does not find any thing
I have word, Word perfect, excel available
Does anyone know the exact syntax?

Thanks

Eric



Report Offensive Message For Removal


Response Number 1
Name: tonysathre
Date: August 22, 2006 at 11:27:28 Pacific
Reply: (edit)

Google for change.com.

"Windows 95 /n./ 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 b


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: August 22, 2006 at 12:18:32 Pacific
Reply: (edit)

So the line is:

zzzlastname, first name: acronym;

Is that right?

And it needs to be changed to:

acronym;


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: August 22, 2006 at 19:00:12 Pacific
Reply: (edit)

If you want to remove the entire line containing the string, try this:

::== chop.bat
@echo off > newfile
set /p chop= string to chop out ?
for /f "tokens=*" %%T in (mydata) do (
echo %%T | find /v "%chop%" >> newfile
)
:: DONE



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: wizard-fred
Date: August 22, 2006 at 22:58:02 Pacific
Reply: (edit)

If the name is in a list occurring on a separate line and you want to remove the extire line, use a macro. First find the desired string, go the beginning of the line,
block mark on, go to end of line, delete line, search for next and repeat. This method works in Word Perfect for DOS (and should work in others).


Report Offensive Follow Up For Removal

Response Number 5
Name: jhunt303
Date: August 23, 2006 at 02:00:46 Pacific
Reply: (edit)

Get your list into Excel and use

=LEFT(B1,3) in column A if your list is in column B

The rest should be easy


Report Offensive Follow Up For Removal


Response Number 6
Name: tobike
Date: August 23, 2006 at 10:44:56 Pacific
Reply: (edit)

[quote]from Mec
So the line is:

zzzlastname, first name: acronym;

Is that right?

And it needs to be changed to:

acronym;
[\quote]

Correct
What I need to do is to remove the recipients’ from a certain acronym
Like I said before I tried to use word to find the acronym and replace it with nothing but it will not pick up the name, also since all e-mail addresses are separated by ; I thought there would be some wild cards I could use that would work


Thanks


Report Offensive Follow Up For Removal

Response Number 7
Name: FishMonger
Date: August 23, 2006 at 11:14:37 Pacific
Reply: (edit)

>> since all e-mail addresses are separated by ; I thought there would be some wild cards I could use that would work

Does that mean that you are tring to search for and edit lines that have email addresses?

Perl or sed would be your best choice for doing the edit, but I don't have a clear picture of the format of your data and exactly what you need to accomplish.

Can you post a few lines of your file for us to work with that are not obfuscated?


Report Offensive Follow Up For Removal

Response Number 8
Name: tobike
Date: August 23, 2006 at 11:52:21 Pacific
Reply: (edit)

Here is what I have:

;Brenan, Norm: #CIO - BPI; Brise, Eric: #CIO-BPI; Bunts, Dan: #LEG;

For example I want all name that have the acronym CIO removed from the list


Report Offensive Follow Up For Removal

Response Number 9
Name: FishMonger
Date: August 23, 2006 at 13:00:08 Pacific
Reply: (edit)

Do you want the entire line removed or just the CIO acronym removed from the line?

If you want to edit the line, but not completely remove it, what do you want it to look like after the edit?


Report Offensive Follow Up For Removal

Response Number 10
Name: wizard-fred
Date: August 23, 2006 at 22:32:33 Pacific
Reply: (edit)

I think what is wanted is to remove all of the entry if it contains the acronym. From the character after the first preceeding semicolon up to an including the next semicolon. Some form of script processor or a dedicated program would probably give the best results. Areas to consider, entry is the first item in list (no leading semicolon), entry is last item in list (no following semicolon), entry spans multiple lines (can the program using the amended list handle long lines).


Report Offensive Follow Up For Removal

Response Number 11
Name: Mechanix2Go
Date: August 24, 2006 at 00:48:37 Pacific
Reply: (edit)

As usual, a clear problem statement is at least 49% of the job.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 12
Name: FishMonger
Date: August 24, 2006 at 13:45:15 Pacific
Reply: (edit)

tobike hasn't given a clear description of what needs to be done, but assuming all lines that have CIO are to be removed, here's a simple Perl command line solution.

perl -ni.bak -e "print if ! /\bCIO\b/" db.txt

If the line needs to be edited rather than removed, the command would be similar. The main difference would be in the construction of the regex (regular expression).


Report Offensive Follow Up For Removal

Response Number 13
Name: tobike
Date: August 25, 2006 at 09:57:59 Pacific
Reply: (edit)

Sorry if it was not clear enough
Kind of hard to explain problems sometimes
Wizardfred read it right and it is what I wanted to do
I did achieve it with a simple word editing software which was notepad plus.

Thanks


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Find and replace

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge