如何用“...”后跟以大写字母开头的文本来分割句子?

问题描述 投票:0回答:1

如何用

'... '
后接以大写字母开头的文本来分割句子?

显示错误:

Lopende tekst...\nVolgende zin.

它应该导致:

Lopende tekst...
Volgende zin.

代码:

<?php
$txt="Lopende tekst... Volgende zin.";
$txt=preg_replace('/(\.{3})( )([A-Z])/','\\1\n\\3',$txt);
echo($txt);
?>
php regex
1个回答
0
投票

单引号

''
没有像转换后的
\n
那样的特殊字符,如果需要,请使用双引号
""
。喜欢:

<?php
$txt="Lopende tekst... Volgende zin.";
$txt=preg_replace('/(\.{3})( )([A-Z])/',"\\1\n\\3",$txt);
echo($txt);
?>
© www.soinside.com 2019 - 2024. All rights reserved.