JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="Lyricstuff" cols="60" rows="10">C CAT cat</textarea>
<button onclick="repl()">Replace</button>
<textarea id="Results" cols="60" rows="10"></textarea>
<span id="rt1">B</span><span id="rs1">C</span>
JavaScript
function repl() {
var lyrics = document.getElementById('Lyricstuff').value;
var find = document.getElementById('rs1').innerHTML;
var spantag = document.getElementById('rt1').innerHTML;
var regex = new RegExp(find, "g");
document.getElementById('Results').value = lyrics.replace(regex, spantag) ;
}