相关疑难解决方法(0)

从字符串中提取以特定字符开头的单词

我得到以下字符串:

 String line = "#food was testy. #drink lots of. #night was fab. #three #four";
Run Code Online (Sandbox Code Playgroud)

我想借此#food #drink #night #three#four从它.

我试过这段代码:

    String[] words = line.split("#");
    for (String word: words) {
        System.out.println(word);
    }
Run Code Online (Sandbox Code Playgroud)

但它给food was testy,drink lots of,nigth was fab,threefour.

java string extraction

4
推荐指数
1
解决办法
9770
查看次数

标签 统计

extraction ×1

java ×1

string ×1