469,602 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Compare two strings, show differences

I want to be able to easily see what changes were made from original
to updated sentences (words added/removed/changed). I'm not too concerned about speed, just looking for something. The compared text will be anywhere from a word or two to multiple paragraphs.

An example:

Original sentence:
The brown dog ran outside at night. During the day, the brown dog slept.

Updated sentence:
The big brown dog ran outside when dark. During the day, it slept.
Ideally, the solution would display the differences in the browser, but I'm open to other ideas (creating txt documents out of the strings and comparing them with Word... but that's a question for another discussion area, purchase something third party, etc.).

Most of what I've found shows which line of text was modified. I'm looking for word differences.

Thank you,
Nathan Rosaaen


Jul 21 '05 #1
2 3087
Nathan,
If you need third party tool, check my Compare It! from
http://www.grigsoft.com/.

If you want to implement it yourself, search for LCS (Longest Common
Subsequence) realization. It will find difference between 2 strings on
char level. If you need word level only, just hash words, your text
will become set of hashes. Same algorithm will compare results and get
you word differences.

If you will have more questions on topic, feel free to contact me
through site's form.

Regards,

Igor Green
http://www.grigsoft.com
Compare It! + Synchronize It! : Files and folders comparison never was
easier!
Jul 21 '05 #2
BeyondCompare

"Nathan Rosaaen" <Na***********@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
I want to be able to easily see what changes were made from original
to updated sentences (words added/removed/changed). I'm not too concerned about speed, just looking for something. The compared text will be anywhere
from a word or two to multiple paragraphs.
An example:

Original sentence:
The brown dog ran outside at night. During the day, the brown dog slept.

Updated sentence:
The big brown dog ran outside when dark. During the day, it slept.
Ideally, the solution would display the differences in the browser, but I'm open to other ideas (creating txt documents out of the strings and
comparing them with Word... but that's a question for another discussion
area, purchase something third party, etc.).
Most of what I've found shows which line of text was modified. I'm looking for word differences.
Thank you,
Nathan Rosaaen

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Prakash RudraRaju | last post: by
4 posts views Thread by Sasidhar Parvatham | last post: by
2 posts views Thread by Nathan Rosaaen | last post: by
3 posts views Thread by Twinkle | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.