Find records containing part of another tab

Help with writing and playing macros

Find records containing part of another tab

Postby mikekiwi » Thu Oct 19, 2006 12:42 pm

Well, that was hard to find a topic title which describes what I mean...and it is so simple.... 8O :wink:

I've got two tabs open:

edit 1 = 25000 records of text with some id's
edit 2 = 10 records containing only a fewid's (each line is one id)

Is it possible to select ("list lines containing string") in one go only those lines of "Edit 1" containing the id's that are present in tab "Edit 2".

Now I do 10 find-commands, but can this be done easier???

Thanks in advance,
Michael
User avatar
mikekiwi
Basic User
Basic User
 
Posts: 10
Joined: Sun Aug 20, 2006 11:00 pm

Re: Find records containing part of another tab

Postby Mofi » Fri Oct 20, 2006 8:23 am

With UE v12.00+ and the Perl regular expression engine and simple IDs you can run a single regular expression find with the 10 IDs in an OR expression like (ID1|ID2|ID3|ID4|ID5|ID6|ID7|ID8|ID3|ID10).

Or you use the following macro which is designed to find all strings from file 2 which contains 1 search string per line and collects the lines found with those strings in the windows clipboard. The macro is similar to the macro posted at equivalent to egrep ??(extract line from big files).

You should have only the 2 files opened and file 2 must have the focus when you start the macro.

Disadvantage of this macro in comparison with a single Perl regular expression search: the lines are sorted by the search strings and duplicate lines are possible. But that can be also an advantage.

The macro temporarily modifies file 1. So it's not possible to have file 1 open in read-only mode. Well, the macro could be rewritten to not modify file 1 and use window/document switches. But this would slow down macro execution a lot.

After executing the macro the windows clipboard contains the lines with any of the search string from the list in file 2. Duplicate lines are possible if a line contains more than 1 search string from the list in file 2.

The macro property Continue if a Find with Replace not found must be checked for this macro.

InsertMode
ColumnModeOff
HexOff
Clipboard 9
Bottom
IfColNum 1
Else
"
"
EndIf
Top
Loop
Find "^p^p"
Replace All "^p"
IfNotFound
ExitLoop
EndIf
EndLoop
SelectAll
Copy
EndSelect
Top
NextDocument
Bottom
IfColNum 1
Else
"
"
EndIf
Top
Paste

"
Clipboard 0
ClearClipboard
Top
Clipboard 9
StartSelect
Key END
Cut
EndSelect
Key DEL
Loop
Find "^c"
IfFound
SelectLine
Clipboard 0
CopyAppend
Clipboard 9
Else
Top
IfCharIs "»"
DeleteLine
ExitLoop
Else
StartSelect
Key END
Cut
EndSelect
Key DEL
EndIf
EndIf
EndLoop
ClearClipboard
Clipboard 0
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros