I am trying to split a string equation into two arrays: numbers and operators.
String expr = "3/20.0"; String numbers = expr.split("[+-/\\*]"); String operators = expr.split("[^+-/\\*]+"); System.out.println(Arrays.toString(numbers)); System.out.println(Arrays.toString(operators));
But my code prints out:
[3, 20, 0] [, /, .]
But I'm trying to get
[3, 20.0] [, /]
I am not sure why the comma is in front of the operators array, but mainly I just want 20.0 to be one element in the numbers array and keep decimal points out of my operators array.