Split String into an array of String

前端 未结 2 382
日久生厌
日久生厌 2021-02-01 18:33

I\'m trying to find a way to split a String into an array of String(s), and I need to split it whenever a white spice is encountered, example

\"hi i\'m pa

2条回答
  •  盖世英雄少女心
    2021-02-01 19:16

    You need a regular expression like "\\s+", which means: split whenever at least one whitespace is encountered. The full Java code is:

    try {
        String[] splitArray = input.split("\\s+");
    } catch (PatternSyntaxException ex) {
        // 
    }
    

提交回复
热议问题