Find right-most byte

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Find right-most byte

Post by gcotterl »

My text file has 1 million lines each 1,274 characters long.

How can I find the line having the number 9 in the rightmost byte?

For example, how do I find the line in red?

0000000000000000000009999900000
0000000099999000000000000000000
9999000000000000000000000000000
0000000000000000000000000999900
0000000000000099999990000000000
0000000000000000000000000000000
0000000000000000099999900000000
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Re: Find right-most byte

Post by ak47wong »

Isn't the rightmost byte of the red line in your example "0"? Are you asking how to find a line where their last character is "9"? If so:

Find what: 9$
[x] Regular expression
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

You are correct.

Ignoring the right-most zeroes, I''m looking for the lines whose last rightmost character is a 9.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Do you mean that you want to find the line whose rightmost 9 is further to the right than it is on any other line (in which case the trailing zeroes are, by implication, ignored)?

I can't see a way to do this in TextPad.
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

The only way I can think of, which is entirely kludgy, is first to search for 9$, and if that doesn't find a match, search for 90$, then 900$, and increase the number of zeros until a match is found.
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

I will make my question clearer:

How can I delete all of the zeroes to the right of the last 9 in each
line?

For example, here are some rows:

0000000000000000000009990000000
0000000099099000000000000000000
9999000000000000000000000000000
0000000000000000000000000099900
0000000000000099999990000000000
0900000000000000000000000000000
0000000000000000099999000000000


This is result I'm looking for:

000000000000000000000999
0000000099099
9999
00000000000000000000000000999
000000000000009999999
09
0000000000000000099999

Then, how do I find the longest line?
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To remove trailing zeroes:
Find what: 0+$
Replace with: [nothing]

[X] Regular expression

Replace All
To remove trailing zeroes only if they follow a 9:
Find what: 90+$
Replace with: 9

[X] Regular expression

Replace All
As already said, you'll have a job getting TextPad to find the longest line.
gcotterl
Posts: 255
Joined: Wed Mar 10, 2004 8:43 pm
Location: Riverside California USA

Post by gcotterl »

Thanks Ben,

Your "To remove trailing zeroes only if they follow a 9:" suggestion did the trick.

Then, to find the longest line, I did several sorts earfch with larger values in the "First Key" box until the longest line was at the bottom.

Gary
Post Reply