2

I have String variable containing string like

{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 }

I want to replace

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

{PDPremium }{covg_si }

FILLIN  PDPremium  \* MERGEFORMAT 

with empty ""

how to write regular expression My program is like this

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

}
3
  • {FILLIN PDPremium \* MERGEFORMATPDPremium } -> {PDPremium } i want like this Commented May 28, 2014 at 5:37
  • Please understand when to use REGEX and when not . if you want to replace a String literal , use string#replace with the String literal as the argument Commented May 28, 2014 at 5:37
  • i have many occurrence like this {FILLIN PDPremium \* MERGEFORMATPDPremium } need to replace all Commented May 28, 2014 at 5:49

1 Answer 1

1

try this:

String p = "FILLIN [^\\\\]+\\\\\\\* MERGEFORMAT";
System.out.println(a.replaceAll(p , "" ));
Sign up to request clarification or add additional context in comments.

1 Comment

PDPremium can be any thing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.