I have this string. I want to remove span having id without removing the data.
Input:
var testString = "<span class="test01">Electrical drafting Scheduling tools <span id="spcc15in0os0">draftin</span><span> </span> Scheduling tools Mechanical</span>"
Expected Output:
"<span class="test01">Electrical drafting Scheduling tools draftin<span> </span> Scheduling tools Mechanical</span>"
I am new to regex. Tried few things.
Try1: testString.replace(/<\/?span\sid=[^>]*>/g, "")
Result: But it is not removing the closing Tag of span
Try2: testString.replace(/(<span id=".*"(?: \w+="[^"]+")*>([^<]*)<\/span>)/gi, "")
Result: it is removing span having id with data.