标点符号上的字符串差异:是preg_split的答案吗?

时间:2021-11-07 22:09:04

http://piratepad.net/IY48xXzsys (modified by Peter West, from the original here: http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/)

http://piratepad.net/IY48xXzsys(由Peter West修改,来自原文:http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/)

Currently a diff between "I think, therefore" and "I think therefore" will produce:

目前,“我认为,因此”和“我认为”之间的区别将产生:

I < del >think,< /del >< ins >think< /ins > therefore

I would like it to produce:

我想要它产生:

I think< del >,< /del > therefore

I think the answer would be to include the comma as a separate entity in the array that results from the preg_split function. I tried to play around with parenthesis, but could not get this to work. Can you help me out?

我认为答案是将逗号作为一个单独的实体包含在preg_split函数的数组中。我试着用括号来玩,但是无法使用它。你能帮我吗?

1 个解决方案

#1


0  

I think that adding a comma to the delimiters in the call to split will do it.

我认为在分割调用中为分隔符添加逗号就可以了。

#1


0  

I think that adding a comma to the delimiters in the call to split will do it.

我认为在分割调用中为分隔符添加逗号就可以了。