sorting numbers and adding zero's to numbers

General questions about using TextPad

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

Post Reply
jan-01
Posts: 19
Joined: Fri Apr 27, 2007 9:40 am

sorting numbers and adding zero's to numbers

Post by jan-01 »

Hello,

I have a problem with sorting numbers
I have a lot of numbers like this

SIG TS 5843
SIG TS 61
SIG TS 793
SIG TS 8603
SIG TS 870
I cannot get them in the right order


Is there a way to add '00' or '000' to numbers
that the program can see TS 870 needs two zero's
and TS 87 needs thee zero's?

Thanks in advance
Jan
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You can sort them in TextPad as they are with a key From column 8, by Numeric comparison.

You get all the numbers to be 5 digits long in steps in a variety of ways, including this:
Find what: \<[0-9]\>
Replace with: 0000\0
Find what: \<[0-9]{2}\>
Replace with: 000\0
Find what: \<[0-9]{3}\>
Replace with: 00\0
Find what: \<[0-9]{4}\>
Replace with: 0\0
jan-01
Posts: 19
Joined: Fri Apr 27, 2007 9:40 am

sorting numbers

Post by jan-01 »

Hello ben-josephs,

Thanks for your reaction
I do not understand "From column 8, by Numeric comparison"
is that a key in textpad?
do I need regular expression?

Is it possibile to use this command in files, because te numbers are in text files:

\DAT 13-11-00
\DAV 20001113
\SIG TS 8602 [K170B]
\EXU g

Is it possible to add the TS to the command so that only the numbers with TS are changed?
Jan
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You said you wanted to sort them. You can do that in TextPad with
Tools | Sort... (or <F9>).
There you will find the settings I suggested.

You can restrict the searches above to lines in which the number is prefixed by TS like this:
Find what: TS ([0-9]{2})\>
Replace with: TS 000\1
etc.

This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
jan-01
Posts: 19
Joined: Fri Apr 27, 2007 9:40 am

sorting numbers

Post by jan-01 »

Hi ben_josehps

Yes I said I wanted to sort them, but did'nt tell you that the numbers where in a file with a lot of tekst.....sory..


This command TS \<[0-9]\>
finds
TS 8
and the replace is
000TS 8

In stead of TS 00008

The command TS \<[0-9]{2}\>
does not work, I think because of
the { } ?

Jan
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Please reread my message carefully and try again.
Post Reply