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: Jens Alfke <email@hidden>
- Date: Sat, 20 Sep 2014 10:53:41 -0700
> On Sep 20, 2014, at 10:43 AM, Scott Ribe <email@hidden> wrote:
>
> There is no simple definition of "the difference between two strings", and I don't think it's a basic need at all.
Usually when programmers talk about "differences" they're referring to something like what a 'diff' tool produces, which is basically a description showing the insertions/deletions that have to be made to the first string to produce the second. This is a very useful type of algorithm that's used a lot in version-control systems, especially because you can later apply the diff output to the first string and reconstruct the second.
Diff algorithms are fairly complex, though, and the details depend a lot on what the granularity of the insertions/deletions is — the usual diff tools consider lines of text as units, but there are "binary delta" algorithms whose units are individual bytes and that will operate on arbitrary data.
I'm still not clear what exactly the OP is asking for. It looks like maybe just a set of the words that are in the second string but not in the first? Keary's solution works well for that.
—Jens
_______________________________________________
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