Replace Space to Hyphen

前端 未结 7 1157

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

String replaceText = \"AT AT\";
replaceText.replace(\' \', \'-\');

7条回答
  •  既然无缘
    2021-02-18 23:44

    If you are replacing many strings you want to consider using StringBuilder for performance.

    String replaceText = "AT AT";
    StringBuilder sb = new StringBuilder(replaceText);
    sb.Replace(' ', '-');
    

提交回复
热议问题