Не используйте split()
. Используйте find()
l oop.
String regex = "[0-9]+\\.?[0-9]*" + // Match number (e.g. 999 or 999.99)
"|\\.[0-9]+" + // Match number (e.g. .999)
"|[a-zA-Z]\\w*" + // Match identifier
"|:=" + // Match complex operator
"|\\S"; // Match other single non-space, incl. operators: +, -, *, /, (, )
Тест
String s = "sum := A+B*( 99.1 +.44 444 1234+++)-sum/232.123459";
String[] splitted = Pattern.compile(regex).matcher(s).results()
.map(MatchResult::group).toArray(String[]::new);
System.out.println(Arrays.toString(splitted));
Выход
[sum, :=, A, +, B, *, (, 99.1, +, .44, 444, 1234, +, +, +, ), -, sum, /, 232.123459]