I have made a Java Interpreter, in which the user may type in operations like the following:
$x+23/$y+9*$z
$x , $y, $z are variables previously defined.
With another piece of code, I will replace those variables with their respective values and then I want to put the string back together.
Example:
$x = 1
$y = 2
$z = 3
So the operation will finally look like this:
1+23/2+9*3
How do I efficiently extract those variables from the main String and fit them back in, given the circumstances that the user might perform operations of different length and order?
$followed by an arbitrary number or characters to get all variables - store them and after that iterate over them to performString#replacewith each variable and its respective value.