How to replace multiple words in a single string in Java?

前端 未结 9 2136
眼角桃花
眼角桃花 2020-12-11 17:09

I\'m writing a program that will replace multiple words in a single string. I\'m using this code but it is replacing word but giving result in two different lines. I want

9条回答
  •  温柔的废话
    2020-12-11 17:20

    Instead of using replace use replaceAll which worked for me

    String strOutput = inString.replaceAll("call me","cm").replaceAll("as soon as possible","asap");
    

提交回复
热议问题