JSFiddle - React, Tailwind, and code Playground
by David Thomas
JavaScript
var editText = '<span class="hover-content" data-hover-id=2 >Some text</span>',
hoverId = editText.match(/\s?data\-hover\-id=(?:['"])?(\d+)(?:['"])?/)[1] || -1;
console.log(hoverId);