Has anyone created a string diff handler?
I want to compare 2 strings and work out the difference between them.
i.e. some kind of function such as strDiff(string1, string2)
which would return the delta change, insertion, or deletion information string2 in order to get back to string1
str1 = "This is a string"
str2 = "This is a new string"
put strDiff(str1, str2)
which would give me something like:
(change char 9 to 10 to "the new")
I though I better check here first to see if anyone has already created this type of function before I make an attempt.
I quickly checked www.mediamacros.com since there are a great deal of scripts housed at that site... but I didn't find any doing a quick search... so I googled and maybe this link will help if you resort to writing your own: http://c2.com/cgi/wiki?DiffAlgorithm
Here's another good link: http://www.somethinkodd.com/oddthinking/2006/01/16/comparing-strings-an-analysis-of-diff-a lgorithms/
Thanks for that.
I'd had already found that first link but found it a bit confusing.
However the second link you gave was new to me and explains it all very well.
I'm going to give it a go...