去除<!--[if gte mso 9]......<![endif]-->字符串

如下代碼可以进行优化
 
/**
 * 清除文本中的ie注释
 * @param content
 * @return
 */
public static String removeIENotes(String content) {
    if(StringUtils.isNotNull(content)) {
        if(content.contains("<![endif]-->")) {
            content = content.substring(content.lastIndexOf("<![endif]-->")+12,content.length());
        }
    }
    return content;

}

 

改良后:提共通,content是前台传过来的字符串,str是包含特殊字符的字符串。

 

public static String removeIENotes(String content,String str) {
    if(StringUtils.isNotNull(content)) {
        if(content.contains(str)) {
            content = content.substring(content.lastIndexOf(str)+str.length(),content.length());
        }
    }
    return content;

}

 

 

 

 

采用此方法在Java端insert,或者update方法中使用,具体如下例子:

String str = "<!--[if gte mso 9]><xml> <o:OfficeDocumentSettings>  <o:RelyOnVML/>  <o:AllowPNG/> </o:OfficeDocumentSettings></xml><![endif]--><!--[if gte mso 9]><xml> ...

...

...

...

...

...

...</xml><![endif]--><!--[if gte mso 10]><style> /* Style Definitions */ table.MsoNormalTable{mso-style-name:普通表格;mso-tstyle-rowband-size:0;mso-tstyle-colband-size:0;mso-style-noshow:yes;mso-style-priority:99;mso-style-parent:"";mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-para-margin:0cm;mso-para-margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:10.5pt;mso-bidi-font-size:11.0pt;font-family:"Arial",sans-serif;mso-ascii-font-family:Arial;mso-ascii-theme-font:minor-latin;mso-hansi-font-family:Arial;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;mso-font-kerning:1.0pt;}</style><![endif]--><span style="mso-bidi-font-size:10.5pt;font-family:&quot;微软雅黑&quot;,sans-serif">近年来,随着世界经济一体化的日益加深,众多跨国企业在华投资,我国大型企业也走出国门在海外投资设厂,无论是政府税务机关还是企业集团总部都不可避免地面临转让定价的问题。关联交易中的转让定价对于集团总部来说是战略行为,对于政府税务机关来说则是税收安全问题。因此,构建符合实际情况的预约定价申请事十分必要的。<span lang="EN-US"></span></span>"

aaa.setFileName(removeIENotes(str));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值