【问题标题】:Replacing unique character with others in android studio在android studio中用其他人替换独特的角色
【发布时间】:2018-01-28 12:10:49
【问题描述】:

我想替换字符串中的某个字符:

"google.com\123"

我想将"\" 替换为"/",以便我的链接正确。

String google = "google.com\123";
google = google.replace("\", "/");

但它不起作用,因为"\" 字符是唯一的。

【问题讨论】:

    标签: android replace special-characters


    【解决方案1】:

    使用此代码

    String google = "google.com\123"; google = google.replace("\\", "/");
    

    这会起作用

    【讨论】:

      【解决方案2】:

      为什么不试试

      String google = "google.com" + "\" + 123"; 
      

      然后添加

      google = goolge.replace("\", "/");
      

      【讨论】:

      • 不起作用。不能用这个“\”替换其他字符
      • 等一下,确保你在“123”左右都有“”
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-28
      • 1970-01-01
      • 2019-12-26
      • 2019-05-10
      • 1970-01-01
      • 2013-10-22
      • 2021-03-05
      相关资源
      最近更新 更多