Diff for single lines

All the diff tools I found just compare line by line instead of char with char. Is there any library that gives detailed information about the lines of one line? Maybe a percentage difference, although I believe that there are separate functions for this?

+7
python diff
source share
4 answers

This algorithm differs by the word:

http://github.com/paulgb/simplediff

available in Python and PHP. It can even spit out the HTML format using the <ins> and <del> tags.

+5
source share

I was looking for something similar recently and came across wdiff . It works on words, not characters, but how close is it to what you are looking for?

+4
source share

What you could try is to split both characters of the string per character into strings, and then you can use diff. This is a dirty hack, but at least it should work and is easy to implement.

Alternatively, you can split the string into a list of characters in Python and use difflib. Check out Python difflib link

+3
source share

You can implement the simple Needleman-Wunsch algorithm . Pseudocode is available on Wikipedia: http://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm

+3
source share

All Articles