How to delete many lines in one run?

Find, replace, find in files, replace in files, regular expressions

How to delete many lines in one run?

Postby rienvanham » Sun Nov 14, 2004 3:57 am

Hello,

I'm often editing large files. I would like to delete many lines in one run.
e.g. I have a text file with the following lines:

A040 line1
A040 line2
A040 line3
A050 line4
A040 line5
A040 line6
etc

I would like to delete the lines starting with A040, so in the "find what" textbox I fill in:
^A040.*$\n
and in the "replace with" textbox:
<nothing>

And now the strange thing happens:
If I click on "start" and then on "replace" (and keep clicking on "replace") all lines with A040 will be deleted.
IF I click on "Replace All" about HALF of the lines will be deleted!

So if I have a textfile with about 100.000 times an A040-line. UE tells me in the first run that about 50.000 lines are deleted; in the second run 25.000 - etc.

How can I delete all the lines in ONE run?

Is it a bug or am I doing something wrong?

With kind regards,

Rien
User avatar
rienvanham
Newbie
 
Posts: 2
Joined: Sun Nov 14, 2004 12:00 am

Re: How to delete many lines in one run?

Postby Mofi » Sun Nov 14, 2004 6:58 am

This is a bug of Replace All. Executing the replace manually works. I know about this special problem since my first version of UE (V6.xx, I think), but I have not written a bug report about it, because I rarely need such a replace.

The problem with Replace All occurs only, if the whole line should be deleted and the next line(s) also, because it fulfills the same search expression and the search expression starts with the symbol for start of line and ends with a line break symbol.

As workaround, use A040.*$\n instead of ^A040.*$\n, if you are sure, that A040 only exists at start of line.

Write a bug report mail to IDM with your example with a link to this forum post.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: How to delete many lines in one run?

Postby rienvanham » Tue Jan 04, 2005 12:27 pm

Mmmmm,

Strange.... they wrote me that it wasn't a bug.... But it's solved in 10.20d.

Thanks a Lot!
User avatar
rienvanham
Newbie
 
Posts: 2
Joined: Sun Nov 14, 2004 12:00 am

Re: How to delete many lines in one run?

Postby pietzcker » Tue Jan 11, 2005 9:18 am

In a similar vein:

I tried a "replace all" to purge a number of CSV files of all occurences of a single "X" as a value which meant searching for ";X;" because all the values are separated by semicolons, and I didn't want it to delete any other "X"s than those that stand "by themselves".

Replacing all ";X;" with ";;" didn't find all ";X;" if two were in a row (e.g., "123;4;X;3;X;X;321" would become "123;4;;3;;X;321"). Sounds like a typical "banana problem" (is there one "ana" or two in "banana"), but not a bug...

Cheers,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm


Return to Find/Replace/Regular Expressions