1

I have a text document that was poorly formatted for my purposes, and I had to make some changes. But now I have another problem, which is a lot of sentences "stranded" on their own, like this:

    \n
    [some text here, bla bla bla.]\n
    \n

Does anyone know of a way to represent a sentence with regular expressions? I want to join these sentences with the paragraph above or below. I swear I searched both Google and this site before asking.

Edit: Sorry, I lost access to my original post, and couldn't comment on Amber's answer. I'll register an account for future questions. Plus, I neglected to mention the fact that I'm using Notepad++.

Yngve
  • 743
  • 4
  • 10
  • 15

1 Answers1

1

How about looking for any pair of newlines with only a single terminating punctuation mark between them? E.g.

\n([^\n.?!]+[.?!][^\n.?!]*)\n

and then just replace that with...

'\n\1 '
Amber
  • 507,862
  • 82
  • 626
  • 550
  • Amber: I tried this, but sadly it didn't work. Might it be beyond the capabilities of Notepad++? But it makes a good starting point, thank you very much. (I wanted to make this an answer to your post, but I couldn't find out how... Maybe I should just give up computers.) – Yngve Sep 23 '11 at 04:44
  • @computer_genius Notepad++ is not able to handle regexes over multiple rows. It looks at each row and remove newline characters before. But there is the extended search mode where you can use `\r` and `\n` (but no regular expressions). See e.g. [this question](http://stackoverflow.com/questions/5381444/finding-and-replacing-blank-lines-regex-in-notepad/5381649#5381649) about finding empty rows – stema Sep 23 '11 at 06:01