Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例子:
abc 123 xyz
预期结果:
123 xyz
这两个字符串可以由一个或多个空格字符分隔。文字是随意的,不能保证空白和非空白字符的数量。
这应该给出所需的输出。
public class Test { public static void main(String[] args) { String s = "abc 123 xyz"; String[] result = s.split("\\s+",2); System.out.println("Result: "+result[1]); } }