I am storing XML in JavaScript variable
<data>
<event>
<eid><![CDATA[152]]]]><![CDATA[></eid>
<start_date><![CDATA[2014-03-01 00:00:00]]]]><![CDATA[></start_date>
<end_date><![CDATA[2014-03-01 00:35:00]]]]><![CDATA[></end_date>
<text><![CDATA[New event]]]]><![CDATA[></text>
<rec_type><![CDATA[]]]]><![CDATA[></rec_type>
<event_pid><![CDATA[0]]]]><![CDATA[></event_pid>
<event_length><![CDATA[0]]]]><![CDATA[></event_length>
<event_type><![CDATA[0]]]]><![CDATA[></event_type>
<event_color><![CDATA[#664d0c]]]]><![CDATA[></event_color>
<userid><![CDATA[1]]]]><![CDATA[></userid>
<mediaid><![CDATA[65]]]]><![CDATA[></mediaid>
</event>
</data>
Now I want to replace all such instances
]]><![CDATA[
from variable
I tried this ?
{
var exp = "/]]><![CDATA[/gi";
alert(exp);
return exp;
}
xmldata = xmldata.replace(getExpReg(), "");
But string is not changed what is the issue ?
.replaceonly accepts a static string (exact match) or a regex object.var exp = new RegExp(""\]\]><!\[CDATA\[","gi");]]><![cdata[also? You have anignore case flag there...