开发者

using delimiter but not delete spaces

开发者 https://www.devze.com 2023-04-02 12:17 出处:网络
I am writing a program where I wa开发者_如何学Gont to split a string separated by comma. My problem is a user can pass or input the string to the program like this:

I am writing a program where I wa开发者_如何学Gont to split a string separated by comma. My problem is a user can pass or input the string to the program like this:

   Hello,,hey,123 

So, is there a way that I can add a space between the hello and hey before I append it to a arraylist. Also my delimiter is ignoring the double ,, and just going to the next word why is that ?


String s = "Hello,,hey,123";
String[] tokens = s.split(",", -1);
0

精彩评论

暂无评论...
验证码 换一张
取 消