Topic: RegExp - columns - groups (1 of 6), Read 56 times
Conf: Search and Replace
From: Chris Tammes
Date: Friday, June 03, 2005 04:30 AM

Hi,

I want to replace 8 characters in a specific position on a line starting with a specific string. Is it possible to define a group as a number of unknown characters?

More specific: the line starts with '22011' and consists of three groups: group 1 is 85 characters, group 2 (to be replaced) is 8 characters and group 3 is the remaining part if the line. Is there a way to define group 1 without having to type 85 dots?

Chris

 


Topic: RegExp - columns - groups (2 of 6), Read 52 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Friday, June 03, 2005 08:11 AM

On 6/3/2005 4:30:01 AM, Chris Tammes wrote:
>Hi,
>
>I want to replace 8 characters
>in a specific position on a
>line starting with a specific
>string. Is it possible to
>define a group as a number of
>unknown characters?
>

Why not use a simple macro solution (where "yyyyyyy" is your
replace string)? E.g.,


reg_set(10,"yyyyyyyy")
repeat(all){
search("|<2201",errbreak)
goto_col(86)
del_char(8)
reg_ins(10)
eol()
}

Fritz

 


Topic: RegExp - columns - groups (3 of 6), Read 52 times
Conf: Search and Replace
From: Chris Tammes
Date: Friday, June 03, 2005 08:33 AM

Fritz,

Yes, that is another solution. I solved it using Ctrl-H and 80 dots in the search string. I was just wondering whether a string repeat command would exist.

Chris

 


Topic: Re: RegExp - columns - groups (4 of 6), Read 54 times
Conf: Search and Replace
From: Christian Ziemski
Date: Saturday, June 04, 2005 02:57 AM

On Fri, 03 Jun 2005 08:11:00 -0400, Fritz Heberlein wrote:

>Why not use a simple macro solution (where "yyyyyyy" is your
>replace string)? E.g.,
>
>
>reg_set(10,"yyyyyyyy")
>repeat(all){
>search("|<2201",errbreak)
>goto_col(86)
>del_char(8)
>reg_ins(10)
>eol()
>}

This version should be a bit faster (no need to first delete 8
characters and then insert 8 ones again):

reg_set(10,"yyyyyyyy")
repeat(all){
search("|<2201",errbreak)
goto_col(86)
reg_ins(10, OVERWRITE)
}


Christian

 


Topic: Re: RegExp - columns - groups (5 of 6), Read 56 times
Conf: Search and Replace
From: Pauli Lindgren
Date: Tuesday, June 14, 2005 03:59 AM

On 6/4/2005 2:57:41 AM, Christian Ziemski wrote:
>
>This version should be a bit faster (no need to first delete 8
>characters and then insert 8 ones again):
>
>reg_set(10,"yyyyyyyy")
>repeat(all){
>search("|<2201",errbreak)
>goto_col(86)
>reg_ins(10, OVERWRITE)
>}

Why to use a register? This is the solution that first came to my mind:

repeat(ALL) {
search("|<2201",errbreak)
goto_col(86)
Ins_Text("yyyyyyyy", OVERWRITE)
}

--
Pauli

 


Topic: Re: RegExp - columns - groups (6 of 6), Read 58 times
Conf: Search and Replace
From: Christian Ziemski
Date: Tuesday, June 14, 2005 09:06 AM

On 6/14/2005 3:59:56 AM, Pauli Lindgren wrote:
>On 6/4/2005 2:57:41 AM, Christian Ziemski wrote:
>>
>>reg_set(10,"yyyyyyyy")
>>repeat(all){
>>search("|<2201",errbreak)
>>goto_col(86)
>>reg_ins(10, OVERWRITE)
>>}
>
>Why to use a register? This is the solution that first came to my mind:
>
>repeat(ALL) {
> search("|<2201",errbreak)
> goto_col(86)
> Ins_Text("yyyyyyyy", OVERWRITE)
>}
>

Fritz used the register in his version and I adopted it because I try to generally avoid hardcodings too.

But you are correct: In this simple example your version is the shortest to answer Chris Tammes' question.

Christian