Regular expression vertical to horizontal

General questions about using TextPad

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

Post Reply
hoachen
Posts: 9
Joined: Mon Nov 24, 2003 1:21 pm

Regular expression vertical to horizontal

Post by hoachen »

Is there a way to have this expression?

The data are horizontal. For example

SomeData A 1 2 3 5 6 8
AlittleData B 2 41 6 8 9 0
MoreData C 7 8 7 8 0 9
FewData D 4 5 7 98 0

Currently, I can do one line at a time to make them vertical like:

SomeData A
1
2
3
5
6
8

Is there an expression to do all at once? Should looks like this:

SomeData A AlittleData B MoreData C FewData D
1 2 7 4
2 41 8 5
3 6 7 7
5 8 8 98
6 9 0
8 0 9 0
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

No, you can't do this in a single step: it's a job for a script. But TextPad doesn't support scripts.

However, you can partially automate the job using macros. You can replace newlines with double newlines and then relace spaces with newlines, to produce this:

Code: Select all

SomeData
A
1
2
3
5
6
8

AlittleData
B
2
41
6
8
9
0

MoreData
C
7
8
7
8
0
9

FewData
D
4
5
7
98
0
With a judicious use of block select mode and the paragraph up and down commands (with and without extending the selection) you can place each paragraph in turn to the right of the first one. Starting with the cursor at the beginning of the first paragraph, you can record a macro for a single paragraph placement, returning the cursor back to the beginning of the first paragraph.

Then replace multiple spaces with single spaces and remove the blank lines.
Post Reply