php – add a line break after a fullstop that has a space after before the next word using regex
im trying to replace any fullstop with whitespace after it before the next word – with a line break.
So far i have tried multiple combinations of regex. I can get to add a line break after a full stop, but then anything with a fullstop and another character immediately after is being broken..
Here’s an example of what im trying to achieve
Babylon. The sound
The result i need
Babylon.
The sound
However the regex im using currently
$info = str_replace('.', "
", $info);
breaks everything with a fullstop –
Example
Babylon.
The Sound v1.2.2
The result
babylon
The Sound v1
2
2
But what i need is as above
Babylon.
The Sound v1.2.2
what regex formula should i be using to get the desired result
Have tried so far
$info = str_replace('.\\s', "\
", $info);
$info = str_replace('.\\b \\b', "\
", $info);
And multiple other attempts. All failing, or breaking after every full stop.
Read more here: Source link
