Debug longest common substring
HTML
<div>
</div>
CSS
div { background-color: white; }
JavaScript
// Define strings
s1 = 'dadxx'
s2 = 'ddxx'
match = (a,b) => {
let re, match, matches=[]
a.split('').forEach((l,i) => {
re = new RegExp(l, 'g')
while ((match = re.exec(b)) != null) {
matches.push([i, match.index])
}
})
return matches
}
document.querySelector('div').innerHTML = JSON.stringify(match(s1,s2))