如何拆分空间java

时间:2013-02-08 05:43:22

标签: java

伙计我需要你的帮助以下查询---- 我有如下字符串:

"Symbol Exchange    Security Type   Mid Extraction time Net Change  Last price  Bid price   Ask price"

我想将其分割如下

"Symbol,Exchange,Security Type,Mid,Extraction time,Net Change,Last price,Bid price,Ask price"

请帮助解决以下问题,因为split(\\s+)没有提供所需的解决方案!

2 个答案:

答案 0 :(得分:2)

假设差距是标签:

String sentence = "Symbol Exchange    Security Type   Mid Extraction time Net Change  Last price  Bid price   Ask price";

String newSentence = sentence.replace('\t', ',');

reference: String.replace()

答案 1 :(得分:0)

你试过这个:

String s = "Your source string";
String m = s.replace(" ", ",");

试试吧。