sorting: how to justify text over a defined column?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
alban berg
Posts: 3
Joined: Mon Nov 10, 2008 10:51 am

sorting: how to justify text over a defined column?

Post by alban berg »

Hello,

I wonder if there is a way to perform the following task:

We are handling very long lists/tables of html-Text which have the
following structure:
<a href="aaaa.html">xxxxxx</a><br>
<a href="bbb.html">yyy</a><br>
<a href="cccc_ccccccc_html">zzzzz zzzz</a><br>
...
...
Since the tags-code until the file-name is always of the same length,
the table can be sorted over all file names (aaaa, bbb, cccc) easily.

However, if we want to sort the text over the linked text (xx, yyyyy, zzz)
we'd have to justify it, before it can be sorted, because the file-names vary in length from line to line. To do this by hand would be too tedious.
What we therefore would like to do is, justify all linked-text chunks
(xx, yyyyy, zzz), telling TextPad to "shift the rest of the line after the first '>' of each line so that it is left-justified along Column X" (and maybe fill up the voids which then could be erased after the sorting has been done).
I hope I have expressed myself clearly,
Any help would be greatly appreciated...
A. Berg
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Insert enough spaces after the >s to shift the remaining text way over to the right with something like the following. The line of underscores represents enough spaces to move all the text to be aligned to the right of all of the first >s:
[Replace the underscores with spaces]

Find what: ^([^>]*)>
Replace with: \1>____________

[X] Regular expression

Replace All
Turn on block select mode. Select a block, one column wide, containing the leftmost column of text to be aligned. (<Shift+Ctrl+Home> and <Shift+Ctrl+End> are useful for this.) Repeatedly replace a single space within that selection by nothing until all the lines of text line up:
[Replace the underscore with a space]

Find what: _
Replace with: [nothing]

[X] Regular expression

Replace All
Keep selecting Replace All until it beeps.
alban berg
Posts: 3
Joined: Mon Nov 10, 2008 10:51 am

Post by alban berg »

Thank you for your hint.
However, I am not sure, if I've got it right...

1. If I use the regEx as indicated by you, it is not found. If I use ^[^>]*> instead, without the (), the desired part of the string after the tag
is indeed highlighted, but
2. if I 'replace' as indicated with \1>___, the whole tag-part will be erased.
That' of course not, what I want. So what is the \1 supposed to
fill in? And what am i doing wrong?
Sorry, but I am not very good at regular Expressions, I must admit.
A. Berg
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Sorry. My suggestion assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
alban berg
Posts: 3
Joined: Mon Nov 10, 2008 10:51 am

Post by alban berg »

Allright, that makes a difference...
Thank you for your kind help.
A.B.
Post Reply