我正在使用diff api工具创建一个很好的差异以显示更改的文本。我正在使用google diff tool来完成此任务。生成diff文本时,它会在每行的末尾生成¶
。我想删除此角色的所有实例。我该怎么做呢?这是该工具的demo。
答案 0 :(得分:1)
以下应该做的工作:
var str = 'abc¶def';
var replaced = str.replace(/¶/g, '');
console.log(str);
console.log(replaced);

但请注意,Diff库本身甚至不返回段落标记:
var dmp = new diff_match_patch();
var diff = dmp.diff_main(inp1, inp2);
// maybe also call dmp.diff_cleanupSemantic(diff);
使用该代码段,您只需在inp1
和inp2
之间收到一系列更改。
答案 1 :(得分:1)
不确切知道您在API上调用的内容很棘手,但这些是您链接的演示中使用的API调用,因此我假设您的返回类似。替换功能仍然是您想要的,您只需要更改您正在搜索的内容。在这种情况下,¶
代替¶
const string1 = `I am the very model of a modern Major-General,
I've information vegetable, animal, and mineral,
I know the kings of England, and I quote the fights historical,
From Marathon to Waterloo, in order categorical.`;
const string2 = `I am the very model of a cartoon individual,
My animation's comical, unusual, and whimsical,
I'm quite adept at funny gags, comedic theory I have read,
From wicked puns and stupid jokes to anvils that drop on your head.`;
const dmp = new diff_match_patch;
const diff = dmp.diff_main(string1, string2);
dmp.diff_cleanupSemantic(diff);
const prettyDiff = dmp.diff_prettyHtml(diff)
console.log('Original:', prettyDiff);
console.log('Replaced:', prettyDiff.replace(/¶/g, ''));

<script src="https://neil.fraser.name/software/diff_match_patch/svn/trunk/javascript/diff_match_patch.js"></script>
&#13;
答案 2 :(得分:0)
MvxAppCompatSetupHelper
&#13;