replace all + with -

后端 未结 6 1472
滥情空心
滥情空心 2021-01-29 06:24

I am trying to replace a + character into a hyphen I have in my string.

String str = \"word+word\";
str.replaceAll(\'+ \', \'-\');
         


        
6条回答
  •  猫巷女王i
    2021-01-29 07:22

    Use "" as opposed to '' in replaceAll.

    String java.lang.String.replaceAll(String regex, String replacement)

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题