How to remove double comma from given below string
String ashok = "RCEX1P.RXCLAIMNBR, RCEX1P.CLMSEQNBR , RCEX1P.CLAIMSTS, ,RCOCDP.APR7N2APUIP1";
expected output should as follows
expected
ashok="RCEX1P.RXCLAIMNBR, RCEX1P.CLMSEQNBR , RCEX1P.CLAIMSTS,RCOCDP.APR7N2APUIP1";
CodePudding user response:
replaceAll
with pattern ",\\s*,"
should do the job
ashok = ashok.replaceAll(",\\s*,",",")
CodePudding user response:
if you know there's always gonna be two spaces between the commas just use replace:
ashok = ashok.replace(', ,',',');