I asked a similar question recently, but I need some more help.
The user will be able to enter a string, for example:
"-5-1/-2"
It needs to: delimit by +,-,*,/,(,) and negative numbers should be kept together, in this case -5 and -2 should stay together.
This is what I currently have:
String userStrWithoutSpaces=userStr.replaceAll(" ", "");
String[] tokens = userStrWithoutSpaces.split("(?<=[\\-+*/=()])|(?=[()\\-+*/=])");
Which works besides keeping negative numbers together.
Thanks in advance.