change the sequence numbers contained in a line

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
CrisCia
Posts: 22
Joined: Thu Nov 13, 2003 7:54 am
Location: Italy

change the sequence numbers contained in a line

Post by CrisCia »

A file contains lines with numbers. These numbers are used in other files.
I want to change the numbering.

File A:..................File B:..................File C:
DG_111_aaa........DG_111_aaa........DG_112_bbb
DG_112_bbb
DG_113_bbb


New numbers:

File A:..................File B:.................File C:
DG_101_aaa........DG_101_aaa........DG_102_bbb
DG_102_bbb
DG_103_bbb
Thank you!

Ciao.

P.S. I'm sorry for my english .... but i try
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Search for: DG_([0-9])1([0-9])_

[X] Regular expression

Replace with: DG_${1}0${2}_

[ ] Literal replacement [i.e., not selected]

Options

Regular expression syntax
[X] Perl/ECMAScript
OR
[X] POSIX Extended

Replacement format syntax
[X] Perl
OR
[X] Extended
CrisCia
Posts: 22
Joined: Thu Nov 13, 2003 7:54 am
Location: Italy

Post by CrisCia »

in this example, I have to do the research for 3 times.

May I replace everything with one command?
Thank you!

Ciao.

P.S. I'm sorry for my english .... but i try
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

What three items?
CrisCia
Posts: 22
Joined: Thu Nov 13, 2003 7:54 am
Location: Italy

Post by CrisCia »

I am sorry, was an incomplete example

File A:..................File B:..................File C:
DG_109_aaa........DG_109_aaa........DG_109_bbb
DG_110_bbb........DG_110_aaa........DG_110_bbb
DG_111_bbb........DG_111_aaa........DG_111_bbb

New numbers:

File A:..................File B:.................File C:
DG_119_aaa........DG_119_aaa........DG_119_bbb
DG_120_bbb........DG_120_aaa........DG_120_bbb
DG_121_bbb........DG_121_aaa........DG_121_bbb
Thank you!

Ciao.

P.S. I'm sorry for my english .... but i try
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I'm assuming the middle digits 0, 1 and 2 are to be increased by 1:

Use conditional expressions:
Search for: DG_([0-9])(?:(0)|(1)|(2))([0-9])_

[X] Regular expression
Replace with: DG_${1}(?2(1):?3(2):?4(3))${5}_

[ ] Literal replacement [i.e., not selected]

Options

Regular expression syntax
[X] Perl/ECMAScript

Replacement format syntax
[X] Extended
Search for conditional expression in WildEdit's help and choose Extended Format String Syntax.

This sort of thing is much more simply done with a script.
CrisCia
Posts: 22
Joined: Thu Nov 13, 2003 7:54 am
Location: Italy

Post by CrisCia »

last case, if I can...

generally, if I want to increase or decrease the sample numbers of 2 ???

File A:..................File B:..................File C:
DG_108_aaa........DG_108_aaa........DG_108_bbb
DG_109_aaa........DG_109_aaa........DG_109_bbb
DG_110_bbb........DG_110_aaa........DG_110_bbb
DG_111_bbb........DG_111_aaa........DG_111_bbb

Increase of 2

New numbers:

File A:..................File B:.................File C:
DG_110_aaa........DG_110_aaa........DG_110_bbb
DG_111_bbb........DG_111_aaa........DG_111_bbb
DG_112_bbb........DG_112_aaa........DG_112_bbb
DG_113_bbb........DG_113_aaa........DG_113_bbb
Thank you!

Ciao.

P.S. I'm sorry for my english .... but i try
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

WildEdit only performs textual manipulation; it can't do arithmetic. So within WildEdit you can only do what you need by a tedious extension of the method I showed you.

Or you can do it with a script.
Post Reply