JSFiddle - React, Tailwind, and code Playground

by Sean Wessell

JavaScript

var htmlString = "<p>The Royal <span class='highlight-keyword highlight-keyword-2 highlight-pid-28' style='font-weight: bold;'>Canadian<span> Navy  (RCN) is the naval force of Canada.<p><p>As of 2015 <span class='highlight-keyword highlight-keyword-2 highlight-pid-28' style='font-weight: bold;'>Canada's</span> navy operates 1 destroyer, 12 frigates, 4 patrol submarines, 12 coastal defence vessels and 8 unarmed patrol/training vessels, as well as several auxiliary vessels.</p>"

var cleanString = $(htmlString).find('span').each(function() {
  $(this).contents().unwrap();
}).end().appendTo('<div/>').parent().html();

console.log(cleanString)