简体   繁体   English

如何从字符串中删除特定字符?

[英]How to delete a specific character from a string?

I'm reading some integer values from a webpage using Java through Jsoup library. 我正在使用Java通过Jsoup库从网页读取一些整数值。 In the website integer represented as xxx,xxx . 在网站整数表示为xxx,xxx I need this set of data to be written in a .csv file so later it can be accessed through Excel for further work. 我需要将这组数据写入.csv文件中,以便稍后可以通过Excel访问以进行进一步的工作。

How to remove this comma in the middle so it doesn't affect the .csv file? 如何在中间删除此逗号,以便它不会影响.csv文件?

string.replace(",", " "); string.replace(“,”,“”); should do it 应该这样做

   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 

当你得到它时它必须是一个字符串,所以可以使用firstInstanceOf来查找然后删除它

I believe that string.replace(",", "") will solve your problem. 我相信string.replace(“,”,“”)将解决您的问题。 This question will help String not replacing characters . 这个问题将帮助String不替换字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM