Hello,

I could really use some help with a project I am working on. The project will basically need to track changes that occur within a string so they can be highlighted.

Ideally the application would spot that change in the string and prehaps inside a new word at the index of the change, say '<span class="Change">' and then the closing tag at the end of the change. I am just having problems with the logic to this, especially in the case where text might not just be added or remove but also used to replaced existing words in a string. If anyone know of similiar projects or is able to point me in the right direction with this, that would be great.

Thanks
Mike

Recommended Answers

All 3 Replies

First notice in C# there is not posssible to alter any string. The string will be allways replaced. There could be possible to keep in safe old version of string.

The project will basically need to track changes that occur within a string so they can be highlighted.

It looks like you need some kind of diff feature for your project.

This is a well-understood problem, and you should be able to find an implementation that meets your needs. One example is the Diff.NET, which includes a library called "MeneesDiffUtils" that may work well for you.

Ideally the application would spot that change in the string and prehaps inside a new word at the index of the change, say '<span class="Change">' and then the closing tag at the end of the change.

A diff library will tell you where all of the changes are, but you're on your own for deciding what to do with them. If you expect to be performing lots of string operations, I recommend you use a StringBuilder.

Great post mate, I will take a look at the link you provided and press on with the issue. Thanks again

It looks like you need some kind of diff feature for your project.

This is a well-understood problem, and you should be able to find an implementation that meets your needs. One example is the Diff.NET, which includes a library called "MeneesDiffUtils" that may work well for you.

A diff library will tell you where all of the changes are, but you're on your own for deciding what to do with them. If you expect to be performing lots of string operations, I recommend you use a StringBuilder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.