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.
String Equation = input.nextLine(); String[] number = Equation.split("\d+");
すべての数字を文字列に分割し、数値にダンプしたいと考えています。どうやって?
等式は: 2x^4 - 45y^4
{2, 4 , 45, 4}; のようにインデックスに番号でダンプする必要があります。
1 つ以上の数字以外の文字で分割できます - \\D+:
\\D+
String[] number = equation.split("\\D+");
\dJava 正規表現を使用している間は、 、などを二重にエスケープする必要があります\D。また、Java の命名規則に従ってください。変数の名前equationは ではなくにする必要がありEquationます。
\d
\D
equation
Equation