比较字符串并获得最终差异 [英] compare strings and get end difference
本文介绍了比较字符串并获得最终差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个字符串.
字符串 A:快速的棕色狐狸"
字符串 B:敏捷的棕色狐狸跳过懒惰的狗."
I have two strings.
String A: "The quick brown fox"
String B: "The quick brown fox jumps over the lazy dog."
字符串 B 将始终逐字包含字符串 A.永远不会有快黑狐"或快速而迅速的棕色狐狸".
String B will always contain string A verbatim. There will never be a "quick black fox" or a "quick and speedy brown fox".
如何获得字符串 C"?区别跳过懒狗".
How do I get a "String C" of the difference "jumps over the lazy dog."?
推荐答案
const A = "The quick brown fox"
const B = "The quick brown fox jumps over the lazy dog."
const diff = (diffMe, diffBy) => diffMe.split(diffBy).join('')
const C = diff(B, A)
console.log(C) // jumps over the lazy dog.
这篇关于比较字符串并获得最终差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文