I want to erase the vacuum in the String.
String input = "java example.java aaa bbb";
String[] temp = input.trim().split(" ");
that result is
java
example.java
aaa
bbb
but i want result that
java
example.java
aaa
bbb
so, i use the split(" +"). The result is right. but i don't understand, how doing the split(" +").
split() takes a regex as it's argument. "+" in regex means "one or more of the previous element". So splitting on " +" will split on "one or more spaces".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With