Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some badly formatted text which I am attempting to reformat using the Writer's Find/Replace functionality which supports regular expressions as defined here.

The problem is some paragraphs have been split into two paragraphs mid-sentence. For example (using ^ to represent the start and $ to represent end of paragraph):

^This is a good paragraph.$

^He said: "This is a good paragraph."$

^But these$

^are two broken ones that should be merged into one.$

I was hoping to construct a regex to find any paragraphs that don't end in a . or " and merge it with the next paragraph (by replacing the end of paragraph with a space, then later I will check for any double spaces).

Doing a find for the search term $ finds (and selects) the end of every paragraph, so it can be replaced. However [^\.]$ finds every paragraph that doesn't end in . but selects the last character not the end of paragraph so I can't replace it.

Any ideas?

share|improve this question

migrated from Aug 24 '11 at 1:34

This question came from our site for professional and enthusiast programmers.

Here's what you want. A negative lookbehind:


However, I don't know if OOo Writers supports negative lookbehinds, so instead you can replace with a captured group.

Find:     ([^."])$\n
Replace:  $1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.