私は正規表現について多くのことを検索しましたが、最終的に文字列を分割するために「\\s+」を使用する方が良いことがわかりました。
しかし驚くべきことに、元の文字列には何もしません:
private static void process(String command) {
command = command.substring(0, command.length() - 1);
String[] splitted = command.split("\\s+");
for (String str : splitted) {
System.out.println(str);
}
}
サンプル入力:
Boolean b = new Boolean(true);
優先出力:
[Boolean,b,=,new,Boolean(true)]
しかし、私のメソッドの出力は次のとおりです。
Boolean b = new Boolean(true)