JSFiddle - React, Tailwind, and code Playground

HTML

<p class="something">
    <a href="http://example.com/9999">text 1 2 3</a>
    <a href="http://example.com/2346saasdf">text 3 4 5</a>
    (9999)
    <a href="http://example.com/sad3ws">text 5 6 7random</a>
</p>

JavaScript

var y = document.getElementsByTagName("p")[0].cloneNode(true);
var x = "";
for(var k in y.childNodes){ 
    if(y.childNodes[k].nodeType == 3){ 
        x += y.childNodes[k].textContent; 
    }
}
x = x.trim();

document.write("<br>text=" + x);