// Поиск всех вхождений
input2.oninput = function(){
let target = this.value;
let targetLength = target.length;
let marker = '<span class="marked">' + target + '</span>';
let markerLength = marker.length + 1;
let searchText = text2;
let pos = -1, idx;
if(targetLength) while((idx = searchText.indexOf(target, pos)) != -1) {
searchText = searchText.slice(0, idx) + marker + searchText.slice(idx + targetLength);
pos = idx + markerLength;
};
result2.innerHTML = searchText;
};