Java 从字符串中删除制表符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23265301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
remove tab chars from the string
提问by Mahmoud Ismail
I have a problem when the string have mix between Arabic and English chars that forced me to add between then \t
or \u0009
but this makes another problem because when the text appear to the customer a lot of spaces "because of tab" between the words appear and the appearance not acceptable, any ideas how to fix this issue?
当字符串在阿拉伯语和英语字符之间混合时遇到问题,这迫使我在那时之间添加,\t
或者\u0009
但这会产生另一个问题,因为当文本出现在客户面前时,单词之间出现了很多“因为制表符”而出现的空格和外观不可接受,任何想法如何解决这个问题?
回答by musefan
You can remove any character/string from a string by using the Replace function. This allows you to specify the string you want to replace, and the value you want to replace it with. When you want to "remove" you simple use an empty string as the replace value.
您可以使用Replace 函数从字符串中删除任何字符/字符串。这允许您指定要替换的字符串以及要替换的值。当您想“删除”时,您只需使用一个空字符串作为替换值。
The following will remove all tab characters:
以下将删除所有制表符:
String result = myString.replace("\t", "")