Topic: FILEGREP - another search/filter macro (1 of 3), Read 42 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Thursday, November 20, 2003 08:54 AM


Here is another search/filter macro.

Imagine this macro as a "grep in a file".

It searches in a structured text with specially marked title or
divider lines for a second string.
Every divided block containing the second string is then listed
with title/divider line and found lines.

The search begins at cursor position and can be using pattern matching
or regular expressions.

Since the macro uses Dialog_Input_1() it requires VEDIT for Windows.

----------------------------------------------------------------------

Example:

#=<>=# block/paragraph 1
some text
more text on mondays
and so on

#=<>=# message 2
another pile of characters
dito

#=<>=# part 3
monday
tuesday

#=<>=# text 4
january
february

--

In the above example file the string "#=<>=#" can be used as divider.
We are searching for blocks containing the string "monday"

Resulting list:

#=<>=# block/paragraph 1
more text on mondays

#=<>=# part 3
monday

----------------------

The macro can be found here:

http://ziemski.privat.t-online.de/vedit/macros/filegrep.vdm


Christian

 


Topic: FILEGREP - another search/filter macro (2 of 3), Read 37 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Friday, November 21, 2003 09:24 AM


New version available: 21.11.2003
- Can now restrict search on a marked block

New version available: 20.11.2003
- Some fixes
- Better error handling
- Some improvements

http://ziemski.privat.t-online.de/vedit/macros/filegrep.vdm


It's really fascinating what one can do with Dialog_Input_1() !


Christian

 


Topic: Re: FILEGREP - another search/filter macro (3 of 3), Read 39 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Thursday, December 11, 2003 03:44 PM


Now I enhanced my filegrep.vdm a bit.

The main new feature is the possibility to grep for whole divisions.


A typical real life example could be:
searching or filtering a standard mail export file.

Every mail in such a file is started with a line like the following:

From name@... Sat Sep 14 22:01:32 2002

and followed by the header and body of the mail.

Using a divider/title search string like

"| (included in the code as example, but initially commented out.)
you can extract all mails containing a given search string.


The menu dialog now looks like:

The following string is
() a title line or
() a divider

Title/div. search string: __________________
using
() pattern matching or
() regular expressions

Contents search string: __________________
using
() pattern matching or
() regular expressions

[] Case sensitive
[] Search &from beginning of file (or block); else from cursor
[] Only within the highlighted &block
[] List divider lines and found contents; else only divider lines
[] List the whole found divison (not only the matching lines)



The macro can be found here:

http://ziemski.privat.t-online.de/vedit/macros/filegrep.vdm


Christian