Topic: Wildcard for digits (1 of 7), Read 136 times
Conf: Search and Replace
From: Peter Rejto
Date: Wednesday, April 12, 2000 06:01 PM

Hi fellow Vedit users:
I would like to replace the string consisting of three digits, say DDD by the string DDD_. For example I would like to replace 123 by 123_.

I have tried the menu command, {Search, Replace} |D|D|D by |D|D|D_ and have chosen the "Pattern Matching" option. Once it worked but then it replaces any string of three digits by the letter string |D|D|D_.

I have a hunch that I am missing something very simple. I would appreciate some help.

-peter.

 


Topic: Wildcard for digits (2 of 7), Read 145 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Wednesday, April 12, 2000 06:28 PM

Peter:

Almost all pattern matching codes don't have a value on the replacement side (cf. manual p.117)

Anyway, you could write a small macro,

-- either one containing the following regular expression:

r("{[0-9][0-9][0-9]}","\1_",regexp+all)

-- or, using pattern matching:

repeat(all){
s("|s|d|d|d",advance+errbreak)
instext("_")}

(The "|s" ensures that only three-digit-strings are altered.)

Fritz

 


Topic: Re: Wildcard for digits (3 of 7), Read 142 times
Conf: Search and Replace
From: Ted Green
Date: Wednesday, April 12, 2000 08:41 PM

At 05:57 PM 4/12/2000 -0400, you wrote:
>I would like to replace the string consisting of three digits, say DDD by
>the string DDD_. For example I would like to replace 123 by 123_.

This is a common question. The answer is to use
"Regular expressions", which is the UNIX standard
pattern matching language that is also available
in VEDIT. Here are the necessary search/replace
strings:

Search: {[0-9][0-9][0-9]}
Replace: \1_

Regular expressions are both verbose and cryptic
with many special character meanings, but they
can perform very powerful search/replace operations.
The VEDIT User's manual has a decent description in
Chapter 4.

Ted.

 


Topic: Re: Wildcard for digits (4 of 7), Read 114 times
Conf: Search and Replace
From: Cliff Wilkie
Date: Sunday, August 19, 2001 02:15 AM

I haven't quite figured out how to search & replace while retaining a portion of the search string.

I want to search a vertical block and replace any occurrence of a string containing, (a colon, any digit, a colon) with (a colon, the digit zero, the same digit as "any digit", a colon).

In other words:

find a text string such as ":2:" and replace it with ":02:"

Using Reg-Exp:
I am searching with :[0-9]:
I am replacing with :0\1:

The search string works OK but the replacement is replacing ":2:" with ":0:" instead of ":02:"

 


Topic: Re: Wildcard for digits (5 of 7), Read 115 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Sunday, August 19, 2001 03:27 AM

Maybe it's easier to use a simple macro:

1. mark your block

2. execute:

repeat(all){
sb(":|d:",bb,be,errbreak)
char()
instext("0")
}

Fritz

 


Topic: Re: Wildcard for digits (6 of 7), Read 113 times
Conf: Search and Replace
From: Christian Ziemski
Date: Sunday, August 19, 2001 12:16 PM


>find a text string such as ":2:" and replace it with ":02:"
>
>Using Reg-Exp:
>I am searching with :[0-9]:
>I am replacing with :0\1:

You have to use :{[0-9]}: as search string.
The '{}' are the grouping characters which are referenced by '\1'.


Christian

 


Topic: Re: Wildcard for digits (7 of 7), Read 109 times
Conf: Search and Replace
From: Ted Green
Date: Monday, August 20, 2001 12:12 PM

At 02:16 AM 8/19/2001, you wrote:
>In other words:
>
>find a text string such as ":2:" and replace it with ":02:"
>
>Using Reg-Exp:
>I am searching with :[0-9]:
>I am replacing with :0\1:
>
>The search string works OK but the replacement is replacing ":2:" with ":0:" instead of ":02:"

The correct search string is: :{[0-9]}:

The "\1" refers to the first {...} group.

Ted.