I have text with paragraph formats, a date is always above each paragraph article. The problem is after each article, there is unknown line breaks that are different kind of unicode line breaks. I need to remove every instance of the line breaks between each paragraph and replace it with two \n\n
.
So from this
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.
To this
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.
I tried using preg_replace()
but it's not matching every instance?
$text = preg_replace('/\r?\n+(?=\d{2}\/\d{2})/', "\n\n", $text);