This question has already been answered:
Hello.
Tell me, please, a suitable regular expression in java to divide the string containing the arithmetic expression into numbers (double) and operations.
For example, after converting the string "15.21 * 6.3", you should get an array of three values "15.21" , "*" and "6.3" .
An example that works for integer:
String input = "4+7"; String[] split = input.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)))"); Result:
split[0] = "4"; split[1] = "+"; split[2]="7"; To get something similar for double has not yet succeeded.
thank