开发者

Trying to manipulate lines in a document with regex

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 o开发者_开发问答riginal 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++.


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 '
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜