New to java/coding and trying to get to grips with it so thank you in advance for the help!
I have this string "s" I am splitting using a set of operators as delimiters.
String[] workableParts = s.split("(?<=[-+*/%^=])|(?=[-+*/%^=])");
I'm storing each split within the workableParts array with the delimiters also stored as part of the array - so for instance an input of 7+7 would be stored as:
workableParts[0]="7"
workableParts[1]="+"
workableParts[2]="7"
I also use this operator array elsewhere:
private String[] ops = {"-","+","*","/","%","^","="};
Is there a way I can use this to replace the text in the split above but maintain the same effect? The idea being that if I add operators at a later date I only have to update them in one place.
Many thanks,
Sam