java - I want to split string with only 2 space although the next string is space -
i want split string 2 space , want next string although next string space
ex. [red blue green orange yellow ]
and result want [red,blue,green, ,orange,yellow, ]
what have do?
try this:
string str = "red blue green orange yellow "; string[] result = arg.split(" "); (int = 0; < result.length; i++) system.out.println(result[i]+',');
this output:
red, blue, green, , orange, yellow,
edit:
if don't want take space of "orange", str.split(" ");
, take items (strings) bigger 1, taking words ignoring blank spaces, couldn't double space string. other way reach want said @ first , use str[i].trim()
in loop, again, won't able take double space string.
anyway, should give more info , details question, did tried before.
Comments
Post a Comment