简体   繁体   English

解析字符串以删除空格

[英]Parsing a string to remove spaces

I have this problem where I have to remove spaces from the string 我有这个问题,我必须从字符串中删除空格

And I want to use parseString 我想使用parseString

Is it okay to use it? 可以使用吗?

Example is 例子是

String one = "ba t , ca t , ra t";
//output should be bat,cat,rat

You can either do 你可以做

one.replaceAll(" ","");

OR 要么

one.replaceAll("\\s","")

Both works! 两者都可以!

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

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