concatenate lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
andrea_baffo
Posts: 2
Joined: Thu Oct 06, 2011 10:32 am

concatenate lines

Post by andrea_baffo »

Hi! I have to append multiple lines but these are not consecutive.
BEFORE

AAAA BBBB
1111 11111
2222 22222
5555 55555

AFTER
AAAA BBBB 2222 2222
1111 1111 5555 5555

Thank you so much!!
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: (.*)\n(.*)\n(.*)\n(.*)
Replace with: \1 \3\n\2 \4

[X] Regular expression

Replace All
andrea_baffo
Posts: 2
Joined: Thu Oct 06, 2011 10:32 am

Post by andrea_baffo »

Thank you so much, It works, you're the best!
And what about if I have three linee to concatenate
BEFORE
First
Fourth
Seventh
Second
Fifth
Eighth
Third
Sixth
Ninth

AFTER
First Second third
Fourth Fifth Sixth
Seventh Eighth ninth

Really Thank you for your time!
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

You could have worked this out yourself.
Find what: (.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)\n(.*)
Replace with: \1 \4 \7\n\2 \5 \8\n\3 \6 \9

[X] Regular expression

Replace All
It won't work beyond \9 in TextPad.
Post Reply