MS Word Wildcards: How to remove carriage return if followed by string

1.3k Views Asked by At

i have a txt file with thousands of lines like:

bla bla bla
bla bla
EMPTYLINE
bla
bla bla
EMPTYLINE
...

what i want is

bla bla bla bla bla
EMPTYLINE
bla bla bla
EMPTYLINE
...

How to do this with wildcards in the find/replace tab?

The logic should be "find any carriage-return or line-end followed by not empty line", but i can't find the right syntax to use.

1

There are 1 best solutions below

1
On

The Find what: ([!^013])(^013)([!^013])

The Replace with: \1 \3

This is divided into three "expressions" (the parentheses define an expression).

The first is: anything except a paragraph mark; the second is: a paragraph mark; the third is: anything except a paragraph mark.

This picks up three characters, of which the first and third should be retained, so "Replace with" uses the backslash markup to insert the first and third expressions in the result. Since the example in the question has a space between the last character of the first paragraph and the first character of the following paragraph there's a space between the two values.