我有一个遵循这种可预测模式的字符串:
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_replaced 字符串应如下所示
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