How to split a String by space

前端 未结 15 1755
傲寒
傲寒 2020-11-22 10:31

I need to split my String by spaces. For this I tried:

str = \"Hello I\'m your String\";
String[] splited = str.split(\" \");

But it doesn\

15条回答
  •  無奈伤痛
    2020-11-22 10:41

    Not only white space, but my solution also solves the invisible characters as well.

    str = "Hello I'm your String";
    String[] splited = str.split("\p{Z}");
    

提交回复
热议问题