Java best way for string find and replace?

后端 未结 7 1435
一生所求
一生所求 2021-02-03 21:38

I\'m looking for the best approach for string find and replace in Java.

This is a sentence: \"My name is Milan, people know me as Milan Vasic\".

I want to repla

7条回答
  •  不知归路
    2021-02-03 22:13

    you can use pattern matcher as well, which will replace all in one shot.

    Pattern keyPattern = Pattern.compile(key); Matcher matcher = keyPattern.matcher(str); String nerSrting = matcher.replaceAll(value);

提交回复
热议问题