Topic: Help Newbie delete strings using wild cards (1 of 10), Read 23 times
Conf: Basic editing, Block operations
From: Jack Carchio
Date: Thursday, March 04, 2010 01:39 PM

I'm a newbie who has some files in which I need to delete a large number of lines. Each line contains a specific word, so it seems like a simple search and replace with wild card characters on either side of the target word would do the trick, but I'm not having much luck following the tutorial.

Any help or suggestions would be greatly appreciated.

 


Topic: Re: No Topic (2 of 10), Read 24 times
Conf: Basic editing, Block operations
From: Fritz Heberlein
Date: Friday, March 05, 2010 05:14 AM

vtech-basic Listmanager schrieb:
> From: "Jack Carchio"
>
> I'm a newbie who has some files in which I need to delete a large number of lines. Each line contains a specific word, so it seems like a simple search and replace with wild card characters on either side of the target word would do the trick, but I'm not having much luck following the tutorial.
>

Given your search string is "nowhere" you can use a macro (at the
command line or save it as a **.vdm file and execute it) like:

repeat(all){
s("|<|*|snowhere|s",ERRBREAK)
dell_line()
}


It searches from begin of line (|<) to (|*) a separator (|s) followed
by "nowhere" and another separater (|s), and deletes the line

Fritz

 


Topic: Re: No Topic (3 of 10), Read 26 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Friday, March 05, 2010 05:36 AM

On 3/5/2010 5:14:52 AM, Fritz Heberlein wrote:
>
>Given your search string is
>"nowhere" you can use a macro like:
>
>repeat(all){
>s("|<|*|snowhere|s",ERRBREAK)
>dell_line()

Fritz, I have to complain ;-)

There is a little typo: dell_line() needs to be del_line().

And it doesn't delete the whole line but only from the current cursor position to the end of line.

To delete a complete line:

BOL() Del_Line(1)


Or one may use the linefilter macro, available in the menu at {Misc, More macors, Linefilter}.


Christian

 


Topic: Re: No Topic (4 of 10), Read 23 times
Conf: Basic editing, Block operations
From: Jack Carchio
Date: Friday, March 05, 2010 07:34 AM

Thanks for the assistance, but as I said, I'm a newbie. I tried using the linefilter macro, but got nowhere with that, so then I tried creating a user macro, per your instructions.

Here is a sample listing of the lines I am trying to eliminate:

[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/accumulators.hpp
[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/accumulators_fwd.hpp
[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/framework
[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/framework/accumulator_base.hpp
[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/framework/accumulator_concept.hpp
[Nov 16 17:36] /load/data/boost1_40/boost/accumulators/framework/accumulator_set.hpp

What each line has in common is:

1. They all start with “[Nov” and
2. They all contain the word “boost”


Now here is the user macro I created:

repeat(all){
s("|<|*|sboost|s",ERRBREAK)
BOL() Del_Line(1)
}

I copied Fritz's macro, replacing the word "nowhere" with "boost" and used Christian's syntax for deleting lines.

I saved this macro, then with the source file open I chose load/exec user macro to run it. Waited ten minutes for the "Waiting for disk" message at the bottom of the screen to disappear and when it finally did there was no change to the file.

What am I still doing wrong?

 


Topic: Re: No Topic (5 of 10), Read 24 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Friday, March 05, 2010 09:31 AM

On 3/5/2010 7:34:17 AM, Jack Carchio wrote:
>
>Here is a sample listing of the lines I am trying to eliminate:
>
>[...]
>
>Now here is the user macro I created:
>
>repeat(all){
>s("|<|*|sboost|s",ERRBREAK)
>BOL() Del_Line(1)
>}

First I have to apologize to Fritz:

In this macro your single Del_Line() is working as expected because the search string contains the begin-of-line and so the cursor is at the correct position.
But it is better and clearer (IMHO) to explicitly delete the complete line.


Jack:

I tried your macro with your data.

It works! Those "boost" lines are deleted.

BTW: You may put a Begin_of_file() at the beginning of your macro to be sure that the complete file is searched. Otherwise the search loop begins at cursor position.

>I saved this macro, then with the source file open I chose
>load/exec user macro to run it. Waited ten minutes for
>the "Waiting for disk" message at the bottom of the screen to
>disappear and when it finally did there was no change to the file.

How big is your file? How many lines?
(I'm just curious, because 10 minutes are a long time for VEDIT.)

>What am I still doing wrong?

I don't know yet.
Strange.

 


Topic: Re: No Topic (6 of 10), Read 26 times
Conf: Basic editing, Block operations
From: Jack Carchio
Date: Friday, March 05, 2010 11:40 AM

Hi Christian,

I believe I figured out what I was doing wrong. Apparently I misunderstood exactly how the macro was supposed to work.

I was under the impression that it would delete any line where the word/string "boost" occurred, regardless of whatever character immediately preceded or followed "boost" but that was not the case. When I tried it again and paid closer attention, I saw that it did delete all the lines containing "boost" but I had other lines with variations (such as ("boost_" and "boost1") that still remained. So I changes the macro to...

repeat(all){
s("|<|*|sboost|*|s",ERRBREAK)
BOL()Del_Line(1)
}

...adding the "|*" wild card after boost and that did the trick. All gone.

Again, thanks for the assistance. Using this macro as an example, I'll be able to clean up all my files now.

Regards...Jack

 


Topic: Re: No Topic (8 of 10), Read 23 times
Conf: Basic editing, Block operations
From: Christian Ziemski
Date: Friday, March 05, 2010 04:14 PM

On 3/5/2010 11:40:07 AM, Jack Carchio wrote:
>
>I was under the impression
>that it would delete any line
>where the word/string "boost"
>occurred, regardless of
>whatever character immediately
>preceded or followed "boost"
>but that was not the case.

That could be done by:

repeat(all){
Search("boost",ERRBREAK)
BOL()
Del_Line(1)
}

 


Topic: Re: No Topic (9 of 10), Read 23 times
Conf: Basic editing, Block operations
From: Pauli Lindgren
Date: Monday, March 08, 2010 05:06 AM

On 3/5/2010 4:14:55 PM, Christian Ziemski wrote:
>
>That could be done by:
>
>repeat(all){
> Search("boost",ERRBREAK)
> BOL()
> Del_Line(1)
>}

That is what I thought. Why to search for beginning of line if you are just searching the word anywhere in the line? The pattern code probably significantly slows down the operation.

Another problem with the original solution is the code |s. If the word "boost" is the first word on the line, the previous line is deleted instead of the searched line.

On the other hand, you can do the same with a single replace command:
Replace("|<|*boost|Y|N", "", ALL)

Or, in the example case, if the folder name must begin with string "boost", you could use:
Replace("|<|*/boost|Y|N", "", ALL)

Alternatively, you could enter the search string and an empty replace string interactively in the replace dialog.

However, the repeat loop without pattern codes is probably faster.

--
Pauli

 


Topic: Re: No Topic (10 of 10), Read 20 times
Conf: Basic editing, Block operations
From: Jack Carchio
Date: Tuesday, March 09, 2010 09:48 AM

Thanks again for the extra suggestions!!

 


Topic: Re: No Topic (7 of 10), Read 25 times
Conf: Basic editing, Block operations
From: Fritz Heberlein
Date: Friday, March 05, 2010 01:24 PM

Professsor Ziemksi!

>Fritz, I have to complain ;-)
>
>There is a little typo: dell_line()
>needs to be del_line().

Shame on me!!

>And it doesn't delete the whole line but
>only from the current cursor position to
>the end of line.
>

It does: with my code the cursor ist at BOL().

Fritz