我有一个如下所示的字符串
String str ='<table height="400" width="600" cellpadding="5" border="0" cellspacing="5" > <tr height="50" valign="top" > <td style=" color:#000000; font-size:12pt; background-color:#FFFFFF; font-family:arial; bLabel:main; bEditID:r3st1;" tEditID="c1r1" locked="0" aEditID="c1r1" > <![CDATA[<div><br></div><div>hi Rajib1 maity1,</div>this is your header<div><br></div>]]></td> </tr> <tr height="300" valign="top" > <td style=" color:#000000; font-size:12pt; background-color:#FFFFFF; font-family:arial; bLabel:main; bEditID:r3st1;" tEditID="c1r2" locked="0" aEditID="c1r2" > <![CDATA[ <div><div>hi Rajib1 maity1,</div>this is your body</div>]]></td> </tr> <tr height="50" valign="top" > <td style=" color:#000000; font-size:12pt; background-color:#FFFFFF; font-family:arial; bLabel:main; bEditID:r3st1;" tEditID="c1r3" locked="0" aEditID="c1r3" > <![CDATA[<div><br></div><div><div>hi Rajib1 maity1,</div>this is your footer</div>]]></td> </tr> </table>';
我想使用apex从字符串中删除"<![CDATA[" and "]]"
。
我尝试了以下内容,
str = str.replaceAll('<![CDATA[','');
str = str.replaceAll('<]]','');
它不起作用。然后我试了
str = str.replaceAll('\\<![CDATA[','');
str = str.replaceAll('\\<]]','');
这也行不通。
有人可以帮帮我吗?
感谢。
答案 0 :(得分:0)
以下作品,
str = str.replaceAll('<!\\[CDATA\\[', ''); // replace '<![CDATA['
str= str.replaceAll('\\]\\]>', ''); // replace ']]'