JSFiddle - React, Tailwind, and code Playground
HTML
<div class="asxdf">asdfasdfx/asdfasdf</div>
<div class="asxdf">asdfasdfxasdf/xxasdf</div>
CSS
.asxdf {
background-color: #dfd
}
.red {
background-color: #f88;
}
JavaScript
$('body').html($('body').html()
.replace(/x(?=[^>]*<)/gi, '<span class="red">x</span>'));