python regular expression to split paragraphs

前端 未结 5 522
执笔经年
执笔经年 2021-01-19 01:40

How would one write a regular expression to use in python to split paragraphs?

A paragraph is defined by 2 linebreaks (\\n). But one can have any amount of spaces/ta

5条回答
  •  清酒与你
    2021-01-19 02:21

    Almost the same, but using non-greedy quantifiers and taking advantage of the whitespace sequence.

    \s*?\n\s*?\n\s*?
    

提交回复
热议问题