Reputation: 23510
I'd like to add a space after any point found with an alphabetic or numeric character just after it (no space found), assuming the next character after the point is not an end of line (cr, lf, ...) character.
preg_replace
"/.[a-z0-9]{1}/"
with "/. [a-z0-9]/i"
How may I do this in PHP ?
Upvotes: 0
Views: 329
Reputation: 1047
You already posted the almost correct answer
$text = preg_replace( '#\.([A-Za-z0-9])#', '. $1', $text );
should do the trick
Upvotes: 2
Reputation: 816482
You can use a positive lookahead:
$str = preg_replace("/\.(?=[a-z\d])/i", ". ", $str);
Upvotes: 5