How to replace a plus character using Java's String.replaceAll method

后端 未结 8 1877
别跟我提以往
别跟我提以往 2020-12-28 11:50

What\'s the correct regex for a plus character (+) as the first argument (i.e. the string to replace) to Java\'s replaceAll method in the String class? I can\'t

8条回答
  •  自闭症患者
    2020-12-28 12:32

    when in doubt, let java do the work for you:

    myStr.replaceAll(Pattern.quote("+"), replaceStr);
    

提交回复
热议问题