0

I have some badly formatted text which I am attempting to reformat using the OpenOffice.org 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?

1 Answer 1

0

Here's what you want. A negative lookbehind:

(?<!\.|")$\n

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

Find:     ([^."])$\n
Replace:  $1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .