Re: return string that is the difference between two other strings
Re: return string that is the difference between two other strings
- Subject: Re: return string that is the difference between two other strings
- From: Allan Odgaard <email@hidden>
- Date: Sun, 21 Sep 2014 08:45:16 +0200
On 21 Sep 2014, at 6:08, 2551 wrote:
As I've been saying all along, this is such a common operation, I'd
have thought there must be a common cocoa method or API for doing it.
So the question is, can anyone tell me what that is?
The general problem you’re dealing with is that of finding the longest
common subsequence. This is a difficult problem so it is often solved
with heuristics. Wikipedia:
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
One solution is the UNIX diff command <x-man-page://1/diff> which, as
Jens previously mentioned, works on lines and is commonly used by
version control systems and programmers. You can call out to this
command from Cocoa (e.g. via NSTask).
You can read about the implementation here
http://www.xmailserver.org/diff2.pdf
An attempt of improving the quality of this command (for source code
diff’ing) exists: http://alfedenzo.livejournal.com/170301.html
If you need a C API then have a look at
https://code.google.com/p/google-diff-match-patch/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden