Topic: Replace wildcards with miltiple lines (1 of 4), Read 53 times, 1 File Attachment
Conf: Search and Replace
From: Dustin Frank
Date: Monday, January 24, 2005 03:03 PM

I am trying to search/replace three characters within a repeating five line + one column block. The characters I am trying to replace all exist in column one (lines 1,2, & 5). Since the characters vary in columns 2-end for each "logical record" (not fixed-length record), wildcards are required.
When I run a search using the criteria "|012 X|*|N|*|N|*|N|*|N|*|N " or "|012 X|M|N|M|N|M|N|M|N|M|N " the block is always found and highlighted like I expect, however when I try to replace these three characters, my output replaces columns 2-end with just "|M" or "|*". I am attaching an image with examples of my input file(left) and my desired output (right). The character replacements per logical record are circled in red. There are over 13,000 records in this file, so you can see why I would not want to do this by hand.

BTW, I am using v6.11.1

 
comparison

 


Topic: Re: Replace wildcards with miltiple lines (2 of 4), Read 47 times
Conf: Search and Replace
From: Ted Green
Date: Monday, January 24, 2005 03:20 PM

At 03:02 PM 1/24/2005, you wrote:
>I am trying to search/replace three characters within a repeating five line + one column block. The characters I am trying to replace all exist in column one (lines 1,2, & 5). Since the characters vary in columns 2-end for each "logical record" (not fixed-length record), wildcards are required.
>When I run a search using the criteria "|012 X|*|N|*|N|*|N|*|N|*|N " or "|012 X|M|N|M|N|M|N|M|N|M|N " the block is always found and highlighted like I expect, however when I try to replace these three characters, my output replaces columns 2-end with just "|M" or "|*". I am attaching an image with examples of my input file(left) and my desired output (right). The character replacements per logical record are circled in red. There are over 13,000 records in this file, so you can see why I would not want to do this by hand.

"|M" and "|*" cannot be used on the replace side.

Since VEDIT's regular expressions do not work well over line boundaries, my probably need to write a custom macro to perform this fixup.

Ted.

 


Topic: Re: Replace wildcards with miltiple lines (3 of 4), Read 49 times
Conf: Search and Replace
From: Dustin Frank
Date: Monday, January 24, 2005 03:39 PM

Thanks Ted, keep up the good work!

 


Topic: Replace wildcards with miltiple lines (4 of 4), Read 50 times
Conf: Search and Replace
From: Christian Ziemski
Date: Tuesday, January 25, 2005 02:50 AM

On 1/24/2005 3:03:48 PM, Dustin Frank wrote:
>I am trying to search/replace three characters within a
>repeating five line + one column block.
>[...]
>There are over 13,000 records in this file, so you can see
>why I would not want to do this by hand.

You can try it with the following RegEx-Replace:

Search string:
"\d012 X{.*}\N{.*}\N{.*}\N{.*}\N{.*}\N "
Replace string:
"1 X\1\N\2\N\3\N\4\N\5\N\d012"


But perhaps it's easier(faster?) to use a simple macro like

Begin_Of_File
repeat(ALL) {
Search("\d012 X{.*}\N{.*}\N{.*}\N{.*}\N{.*}\N ", REGEXP+NOERR+ERRBREAK)
if (! Error_Match) {
Ins_Char(49, OVERWRITE)
Line(1)
Ins_Char(3, OVERWRITE)
Line(5)
Ins_Char(12, OVERWRITE)
}
}


Christian