Php 放一个<;br>;在某些字符之间

Php 放一个<;br>;在某些字符之间,php,regex,Php,Regex,我有一个字符串遵循这种可预测的模式: This is a string, it has a comma in it, This is another string, it also has a comma in it, This is a third string, it follows the trend 等等 显然,该字符串表示一个列表,由逗号分隔。仅此而已,列表的项目中也有逗号。确定新项目开头的方法是大写字母 我设法将模式与此匹配:[,\p{Lu}],但我不确定下一步该做什么。如果我使用

我有一个字符串遵循这种可预测的模式:

This is a string, it has a comma in it, This is another string, it also has a comma in it, This is a third string, it follows the trend
等等

显然,该字符串表示一个列表,由逗号分隔。仅此而已,列表的项目中也有逗号。确定新项目开头的方法是大写字母

我设法将模式与此匹配:
[,\p{Lu}]
,但我不确定下一步该做什么。如果我使用
preg_split()
我会丢失所需的逗号,但也会丢失不需要的大写字母。正确替换的preg_字符串应该如下所示

This is a string, it has a comma in it<br />
This is another string, it also has a comma in it<br />
This is a third string, it follows the trend
这是一个字符串,其中有一个逗号
这是另一个字符串,其中还有一个逗号
这是第三个字符串,它遵循趋势
使用:

$result=preg_replace('/,(?=\p{Lu})/u','
\n',$subject);

正则表达式的意思是“匹配
和空格,但前提是它们后面跟一个大写Unicode字母”。这样,字母就不会成为匹配本身的一部分。

对它进行了一些调整:
$result=preg\u replace('/,(?=\p{Lu})/u','
',$subject)要替换的空格和不必要的换行符,因为单引号,我怀疑这不能正常工作。但谢谢你,在你指出之前,我不知道前瞻。
$result = preg_replace('/, (?=\p{Lu})/u', '<br />\n', $subject);