替换常规换行符和unicode换行符

时间:2013-10-31 00:27:25

标签: php regex

我有段落格式的文字,日期始终高于每个段落文章。问题是在每篇文章之后,有未知的换行符,这是不同类型的unicode换行符。我需要删除每个段落之间的换行符的每个实例,并用两个\n\n替换它。

所以从这个

05/12
The 1959 Mexico hurricane was a devastating tropical cyclone
that was one of the worst ever Pacific hurricanes. It 
impacted the Pacific coast of Mexico in October 1959. The
hurricane killed at least 1,000 people.




11/01
The 1959 Mexico hurricane was a devastating tropical cyclone
that was one of the worst ever Pacific hurricanes. It 
impacted the Pacific coast of Mexico in October 1959. The
hurricane killed at least 1,000 people.

到此

05/12
The 1959 Mexico hurricane was a devastating tropical cyclone
that was one of the worst ever Pacific hurricanes. It 
impacted the Pacific coast of Mexico in October 1959. The
hurricane killed at least 1,000 people.

11/01
The 1959 Mexico hurricane was a devastating tropical cyclone
that was one of the worst ever Pacific hurricanes. It 
impacted the Pacific coast of Mexico in October 1959. The
hurricane killed at least 1,000 people.

我尝试使用preg_replace(),但它不匹配每个实例?

$text = preg_replace('/\r?\n+(?=\d{2}\/\d{2})/', "\n\n", $text);

0 个答案:

没有答案