I’ll be using the cjsDiff library
M9zcCXivXIkjpW_mA_X1Vtiz3TLx7pV4j
You can report on any combination of additions, deletions or no changes. This example does them all.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// compare var diffs = cjsDiff.JsDiff.diffChars( 'quick brown fox jum ove lazy dog', 'the quick brown fox jumped over the lazy dog' ); Logger.log("\n" + diffs.map(function (d) { if (!d.removed && !d.added ) { return 'no changes--'+d.count + ' chars\n '+d.value; } if (d.removed) { return 'removed--' + d.count + ' chars\n '+d.value; } if (d.added) { return 'added--' + d.count + ' chars\n '+d.value; } }).join ("\n")); |
And the result
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
added--4 chars the no changes--19 chars quick brown fox jum added--3 chars ped no changes--4 chars ove added--1 chars r no changes--1 chars added--4 chars the no changes--8 chars lazy dog |
If that doesn’t quite do it for you, There are various options you can use as documented here
Why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available.