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.
文字列があるとします
s ="[ 2323.2323 232.3232 0.2 0.3 3232]"
スペース区切りで文字列の配列に分割したい。また、値の間に単一のスペースを保持し、複数のスペースを無視したいと考えています。
これを行うための正規表現は何でしょうか?
最初に複数のスペースを取り除きます:
String after = before.trim().replaceAll(" +", " ");
次に、分割メソッドを使用して文字列を配列に分割します