Topic: incert decimal point in five digit number (1 of 6), Read 89 times
Conf: Search and Replace
From: Vijay Jain
Date: Friday, November 23, 2001 08:12 PM

Hi all:

I am a new Vedit user and need to search & replace five or six digit number in a text file and replace with the same number inserting a decimal point after first three digits.

I tried {[0-9][0-9][0-9][0-9]0-9]} and replace with \1\.\2\.

It finds number, which has any number of digit. But I need only five digit numbers to be picked for replacement.

Any help will be greatly appreciated.

Thank you,

Vijay

 


Topic: Re: incert decimal point in five digit number (2 of 6), Read 90 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Saturday, November 24, 2001 03:49 AM

> I am a new Vedit user and need to search & replace five or six digit number in a text file and replace with the same number inserting a decimal point after first three digits.

I'm not familiar with regular expressions, but you could do it with a
little macro.
Assuming that your numbers are at left margin you could do ("|<" is
"left margin"):

while(!At_EOF){
search("|<|d|d|d|d|d",errbreak)
char(3)
Ins_Text(".")
}

Otherwise, if your your numbers are scattered across tht file
you could try ("|s" is any separator, e.g. a blank):


while(!At_EOF){
search("|s|d|d|d|d|d",errbreak)
char(4)
Ins_Text(".")
}

Fritz
Dr. Friedrich Heberlein, Akad. Direktor
Seminar für Klassische Philologie
KU Eichstaett
Universitaetsallee 1
D-85071 Eichstaett / Bayern

email: sla019@...
Tel.: +49 8421 93 1544 / 93 3544

 


Topic: Re: incert decimal point in five digit number (4 of 6), Read 81 times
Conf: Search and Replace
From: Pauli Lindgren
Date: Wednesday, November 28, 2001 05:08 AM

>
>
>while(!At_EOF){
>search("|s|d|d|d|d|d",errbreak)
>char(4)
>Ins_Text(".")
>}

That would only find a number that is preceded with empty space, but not e.g. a number in parenthesis (12345). In addition, it would find numbers with 6 or more digits, too.

Try this macro:

Repeat(ALL) {
  Search("|!|D|D|D|D|D|D|!|D",ERRBREAK)
  Char(4)
  IC('.')
}

-- Pauli

 


Topic: Re: incert decimal point in five digit number (5 of 6), Read 81 times
Conf: Search and Replace
From: Fritz Heberlein
Date: Wednesday, November 28, 2001 06:04 AM

> >while(!At_EOF){
> >search("|s|d|d|d|d|d",errbreak)
> >char(4)
> >Ins_Text(".")
> >}
>
> That would only find a number that is preceded with empty space, but not e.g. a number in parenthesis (12345).

Well, according to its definition:

Match any separator - a character which is not a letter, a
digit or underscore

"|s" should find should find numbers in parentheses as well, and in
fact, it does, at least on my machine :))

Fritz

 


Topic: Re: incert decimal point in five digit number (6 of 6), Read 83 times
Conf: Search and Replace
From: Ted Green
Date: Wednesday, November 28, 2001 09:10 AM

At 06:04 AM 11/28/2001, you wrote:
>Well, according to its definition:
>
> Match any separator - a character which is not a letter, a
> digit or underscore
>
>"|s" should find should find numbers in parentheses as well, and in
>fact, it does, at least on my machine :))

Fritz is technically correct here, but Pauli is correct about matching five digits and not six or more. The difference between |S and |!|D would be important with a string such as "X12345ABC"; should it be matched or not.

Ted.

 


Topic: Re: incert decimal point in five digit number (3 of 6), Read 91 times
Conf: Search and Replace
From: Christian Ziemski
Date: Saturday, November 24, 2001 12:33 PM

Try it with:

Search: {[0-9][0-9][0-9]}{[0-9][0-9]}{[^0-9]}
Replace: \1\.\2\3

Unfortunately that doesn't work with numbers at end_of_line.
But maybe someone knows a solution for that.

Christian