I have problem with: cursor position.
Is starting from the beginning
$('div').on('keyup', function () {
var search = $(this),
pattern = /(SELECT|FROM|WHERE|DELETE)/gi,
result = search.text().replace(pattern, '<span class="sql">$1</span>');
$(this).html(result);
$('p').html(result);
});
My fiddle: https://jsfiddle.net/yoxkjouf/
How to fix this problem