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 エクシーズ
2 つの文字列は、1 つ以上の空白文字で区切ることができます。テキストは自由であり、空白および非空白文字の数に対する保証はありません。
これにより、目的の出力が得られるはずです。
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]); } }