我有包含像这样的字符串的String变量

{IF {FILLIN  PDPremium  \* MERGEFORMATPDPremium }= " 0.00" "" "Property DamageSectionInsured ItemsSum Insured( {FILLIN  si_curr  \* MERGEFORMATsi_curr })Premium( {FILLIN  si_curr  \* MERGEFORMATsi_curr }) {FILLIN  covg_desc_temp  \* MERGEFORMATcovg_desc_temp } {FILLIN  covg_si  \* MERGEFORMATcovg_si } {FILLIN  covg_prem  \* MERGEFORMATcovg_prem }"pol_tc_cdpol_tc_desc }


我要更换

{FILLIN  PDPremium  \* MERGEFORMATPDPremium } `{FILLIN  covg_si  \* MERGEFORMATcovg_si }


{PDPremium }{covg_si }

FILLIN  PDPremium  \* MERGEFORMAT


空的""

如何写正则表达式
 我的程序是这样的

public static void main(String[] args) {
    String a = "IF {FILLIN  PDPremium  \\* MERGEFORMATPDPremium }";
    System.out.println(a.replaceAll( "(?i)(FILLIN[^>]*?\\sMERGEFORMAT\\s*)", "" ));

}

最佳答案

尝试这个:

String p = "FILLIN [^\\\\]+\\\\\\\* MERGEFORMAT";
System.out.println(a.replaceAll(p , "" ));

10-06 09:45