Concatenate lines of text omitting blanks lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
drifus
Posts: 5
Joined: Thu Oct 19, 2006 2:57 pm

Concatenate lines of text omitting blanks lines

Post by drifus »

I have searched the forum and couldn't find exactly what I am looking for.

Before Data:

text
text
text
text
blank line
blank line

After Data:
text text text text
Blank Line
text text text text
Blank Line

The Text Lines can be almost any amount.
The blank lines can also be any amount.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: ^(.+)\n(.+)
Replace with: \1 \2

[X] Regular expression

Replace All
Replace All repeatedly until it beeps.

Then
Find what: \n\n
Replace with: \n

[X] Regular expression

Replace All
Replace All repeatedly until it beeps.

These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Replace

Code: Select all

\n([^\n])
(i.e. a line-break followed by something other than a line-break) by

Code: Select all

\1
(i.e the "something other than a line-break)

(in Textpad: Posix Regular Expression Syntax must be checked!)
drifus
Posts: 5
Joined: Thu Oct 19, 2006 2:57 pm

Post by drifus »

Thank you both, now I am a lot closer to finishing my data manipulation.
Post Reply