昨晚在这里回答了第一轮.@Reimeus提供的解决方案很棒,并提供以下输出:
My name is the mighty llama
Run Code Online (Sandbox Code Playgroud)
至:
String[] stringArray = string.split("(?<!\\G\\S+)\\s");
My name
is the
mighty llama
Run Code Online (Sandbox Code Playgroud)
但是,我现在发现自己需要纠正我正在做的事情.我实际上需要能够像这样拆分字符串.
My name
name is
is the
the mighty
mighty llama
Run Code Online (Sandbox Code Playgroud)