Here are our strings:
const a = "your majesty they are ready";
const b = "your highness they are ready";
I want to get one array containing the longest exact matches between two strings.
So for the first string, we would get:
[ ["your"], ["they are ready"] ]
NOT this result which gets the shortest matches:
[ ["your"], ["they"], ["are"], ["ready"] ]
Getting a word match is an easy task for me. But I need a hand to figure out a proper solution the get the longest possible exact matches...
And by the way I'm using this function to check the exact matches:
// exactMatch("I was sent","sent") returns true And exactMatch("I was sentt","sent") returns false
function exactMatch(ref,compare) {
return new RegExp("\\b" + ref + "\\b").test(compare);
}
Note: I don't want just the longest match... I want all longest possible matches.