I have the SVG string as below:
var svgstring = '<g font-size="1.6" font-family="DejaVu Sans" stroke="none" fill="#000000"><rect x="254.01" y="50.00" width="29" height="2.24" stroke="#053581" stroke-width="0.1" fill="#b2b8c3"></rect><text x="254.21" y="51.6" font-size="1.6" font-weight="700" font-family="DejaVu Sans" stroke="none" fill="#000000">Cav.</text><text x="259.21" y="51.6" font-size="1.6" font-weight="700" font-family="DejaVu Sans" stroke="none" fill="#000000">Wire</text><text x="267.21" y="51.6" font-size="1.6" font-weight="700" font-family="DejaVu Sans" stroke="none" fill="#000000">Colour</text><text x="274.21" y="51.6" font-size="1.6" font-weight="700" font-family="DejaVu Sans" stroke="none" fill="#000000">Gauge</text><rect x="254.01" y="52.24" width="29" height="2.24" stroke="#053581" stroke-width="0.1" fill="#ffffff"></rect><text x="254.21" y="53.84" fill="#000000"> 1</text><text x="259.21" y="53.84" fill="#000000"> FPTO-20..</text><rect x="267.01" y="52.34" width="7" height="2.04" stroke-width="0.01" fill="#C1D5D9"></rect><text x="267.21" y="53.84" fill="#000000">GY</text><text x="274.21" y="53.84" fill="#000000"> 0.75</text><rect x="254.01" y="54.48" width="29" height="2.24" stroke="#053581" stroke-width="0.1" fill="#fff8c6"></rect><text x="254.21" y="56.08" fill="#000000">2</text><text x="259.21" y="56.08" fill="#000000">FPTO-20..</text><rect x="267.01" y="54.58" width="7" height="2.04" stroke-width="0.01" fill="#EDEDED"></rect><text x="267.21" y="56.08" fill="#000000">WH</text><text x="274.21" y="56.08" fill="#000000">0.75</text><line x1="259.01" y1="50.00" x2="259.01" y2="56.72" stroke="#053581" stroke-width="0.1" fill="#053581"></line><line x1="267.01" y1="50.00" x2="267.01" y2="56.72" stroke="#053581" stroke-width="0.1" fill="#053581"></line><line x1="274.01" y1="50.00" x2="274.01" y2="56.72" stroke="#053581" stroke-width="0.1" fill="#053581"></line></g>'
I need to replace all the occurrence of text tag with empty. I have used the following code :
var textstring = svgstring.match('(<text.*<\/text>)');
if(textstring[1]){
textstring = textstring.replace(textstring[1],"");
}
But it is replacing every thing including the rect tags inside it and getting the following result:
<g class='DG56 bundleGroup'><image width="3" height="3" transform="translate(248.01,46.5)" xlink:href="images/icons/plug.svg"></image><rect etype ="connector" nodex = "249.01" nodey = 50.00 stroke="#fff" fill="#fff" fill-opacity="0" stroke-opacity="0" transform="translate(249.06,47.15)" width="1.15" height="1.84" ondblclick="app.gui.editProperties('249.01', '50.00');" onclick="app.drawing.ConSpliceClick('56', evt, '249.01', '50.00');" /><g node="127"><g transform="translate(259.01,55.00) scale(1 1) rotate(0)"><image width="25" height="25" xlink:href="taskassets//noImage.jpg?key=1444900697"/></g></g><g node='126'><g font-size="1.6" font-family="DejaVu Sans" stroke="none" fill="#000000"><rect x="254.01" y="50.00" width="29" height="2.24" stroke="#053581" stroke-width="0.1" fill="#b2b8c3"/></g></g>
But I need to replace only <text ... </text>
. Please help me with this.