【问题标题】:How to delete a specific character from a string?如何从字符串中删除特定字符?
【发布时间】:2014-03-19 14:37:05
【问题描述】:

我正在通过 Jsoup 库使用 Java 从网页中读取一些整数值。在表示为xxx,xxx 的网站整数中。我需要将这组数据写入 .csv 文件,以便以后可以通过 Excel 访问它以进行进一步的工作。

如何去掉中间的这个逗号,不影响.csv文件?

【问题讨论】:

  • thisIsTheString.replace(",","");... 或许可以表现出你的一些努力
  • 我完全不以为然......我想我应该去那个逗号的索引并手动删除它

标签: java string csv jsoup


【解决方案1】:

string.replace(",", "");应该这样做

【讨论】:

    【解决方案2】:
       if you want to remove any charactor from a string you can use it.
    
       String name="sri,sha,ila,m";
    
       name = name.replace(",","");
    
       Output : srishailam 
    

    【讨论】:

      【解决方案3】:

      获取时必须是字符串,所以可以使用 firstInstanceOf 查找然后删除它

      【讨论】:

        【解决方案4】:

        我相信 string.replace(",", "") 会解决你的问题。 这个问题对String not replacing characters有帮助。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-12-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多