我有一个这样的字符串: String attributes = " foo boo, faa baa, fii bii,"
我想得到这样的结果:
String[] result = {"foo boo", "faa baa", "fii bii"};
所以我的问题是如何分割和修剪在一个镜头我已经分割:
String[] result = attributes.split(",");
但 spaces
仍然在结果中:
String[] result = {" foo boo", " faa baa", " fii bii"};
^ ^ ^
我知道我们可以做一个循环,使 trim
为每一个,但我想使它在镜头。