开发者

String diff on punctuation: is preg_split the answer?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜