Find and replace text with a line break in the middle?

I have many instances of text that look like:

...blah blah "
            + "blah blah...

And I’m trying to turn it into:

…blah blah blah blah…

I can identify the end of the first line just fine with: "$
And I can identify the beginning of the second line just fine with: ^\s{0,20}\+\s"

But of course combining them into one expression doesn’t work, since $^ is probably nonsensical in regex. And if I try to replace them with empty separately, the CrLf persists. Any ideas or is this just not possible? Thx

Perhaps, you should take a look at the code of OOoFBTools, the JoinBreakLine module (or just use the extension).

if you’re looking to concatenate text in 2 cells, say, try =cell1 &" " & cell2

Note this question is tagged Writer; and the question possibly could have been phrased as “How do I replace a line break with a space?”

@robleyd: replacing a line break is relatively easy but a paragraph mark in this context can’t.

luber1: thanks for helping, but this is actually a writer regex question.
robleyd: you’re right, I should have included find and replace in the question title. I think I might be able to edit it.

Built-in Edit>Find & Replace operates at most on a paragraph. Paragraph breaks are considered delimiters and are outside of the operating range. ^ is the paragraph mark preceding but not included the target pattern and $ is the one following but not included the target pattern.

Consequently, as you guessed $^ does not make sense because it means “the position at end of the paragraph followed by the position before the same paragraph”.

^$ is a special pattern to find empty paragraphs. This pattern can be replaced by “nothing”, effectively deleting the paragraph mark.

In case your line wrap is caused by a line break (Shift+Enter) instead of a regular paragraph break (Enter), it does not create a paragraph break (as the name implies), the line break can be replaced with a regular expression like:

 ' "\n\s{0,20}\+\s"'  ==> ' '

(quotes added to make the spaces visible).

Otherwise, you have two possibilities:

  • You didn’t describe the characteristics of the sequences you want to transform. They look like some programming snippets, meaning they were copied from some source file (in format .txt or the like). It is then easier to process these files before extracting the bits and pasting them into Writer. You can do that easily with sed, awk, perl, grep or even bash or combination of them.

  • Install AltSearch extension which is not limited to a single paragraph and may cross paragraph boundaries.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

@ajlittoz: AltSearch worked for me, thx. The regex was “\p\s{0,20}\+\s” . Your intuition was correct, this is a Java <String,Integer>Hashmap that got way, way, way too big and needed to be put into a SQL tbl. Thanks again.