An easy-to-use character-filtering, diff-Matching Patch extension library for each language version

Source: Internet
Author: User
Tags diff lua

Diff-match-patchgithub Address

Support C,java,javascript,lua,object-c,python

Https://github.com/google/diff-match-patch/wiki/API

The library is available in multiple languages. Regardless of the language used, the interface is the same. This page describes the API for public functionality. More instances at the top address .

each language port of the Diff Match patch is used the same API

Java version

Importjava.util.LinkedList;ImportName.fraser.neil.plaintext.diff_match_patch; Public classHello { Public Static voidMain (String args[]) {diff_match_patch dmp=NewDiff_match_patch (); LinkedList<diff_match_patch. diff> diff = Dmp.diff_main ("Hello World", "Goodbye."); //Result: [( -1, "Hell"), (1, "G"), (0, "O"), (1, "Odbye"), (0, "World")]dmp.diff_cleanupsemantic (diff); //Result: [( -1, "Hello"), (1, "Goodbye"), (0, "World")]System.out.println (diff); }}

Lua version, but bugs are unavoidable because LUA strings do not have the encoding rules set by default when initializing, and all byte rules need to be defined by themselves, so this version of LUA needs to build its own wheels.

LocalDMP =require 'Diff_match_patch'diff= Dmp.diff_main ('Hello World.','Goodbye World.')--Result: [( -1, "Hell"), (1, "G"), (0, "O"), (1, "Odbye"), (0, "World")]dmp.diff_cleanupsemantic (diff)--Result: [( -1, "Hello"), (1, "Goodbye"), (0, "World")] forI,tupleinch Ipairs(diff) Do  Print('('.. tuple[1] ..', '.. tuple[2] ..')')End

An easy-to-use character-filtering, diff-Matching Patch extension library for each language version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.