开发者

String diff on punctuation: is preg_split the answer?

开发者 https://www.devze.com 2023-03-12 01:52 出处:网络
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 (modified by Peter West, from the original here: http://paulbutler.org/archives/a-simple-diff-algorithm-in-php/)

Currently a diff between "I 开发者_Python百科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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消