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.
精彩评论