• 一个好用的字符过滤,差异匹配补丁的扩展库,各语言版本


    diff-match-patchgithub地址

    支持c,java,javascript,lua,object-c,python

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

    该库有多种语言版本。不管使用什么语言,使用它的界面都是一样的。该页面描述了公共功能的API。更多实例在上方地址

    Diff Match Patch的每个语言端口都使用相同的API

    java版本

    import java.util.LinkedList;
    import name.fraser.neil.plaintext.diff_match_patch;
    
    public class hello {
      public static void main(String args[]) {
        diff_match_patch dmp = new diff_match_patch();
        LinkedList<diff_match_patch.Diff> 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.")]
        System.out.println(diff);
      }
    }

    lua版本,不过bug是免不了的因为lua字符串不像更高级的语言会在初始化时默认设置编码规则,所有的字节规则需要自己定义,所以这个版本的lua需要自己造轮子

    local dmp = 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.")]
    for i,tuple in ipairs(diff) do
      print('(' .. tuple[1] .. ', ' .. tuple[2] .. ')')
    end
  • 相关阅读:
    IOS 线程 +并发
    ios
    ios
    ios uitableviewcell动态计算高度
    ios 画圆环进度条
    ios -几种常见定时器
    ios 加载本地html css文件 ps:css和html必须在同一文件夹下面
    UISegmentedControl 分段器加载不同的viewcontroller
    iOS ----Pods-resources.sh Permission denied
    UIView的layout(布局)与draw(绘图)
  • 原文地址:https://www.cnblogs.com/dmeck/p/8510603.html
Copyright © 2020-2023  润新知