Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Extracting operands and operators from a string calculation

807603Jan 27 2008 — edited Jan 30 2008
Hi there,

I hope you all understand my question, well here it goes.
Basically all I am trying to do is take out the operators( -, +, /, *, %, ^ ) and operands(integers) from the user's input string which is this:
BufferedReader cmdLine = new BufferedReader(new InputStreamReader(System.in));
 String inLine = "";
 while((inLine = cmdLine.readLine()) != null) {
          //extraction code required here
          System.out.println(""//answer);
 }
A typical user input can be like these examples:
String input1 = "4 + 3 * 4";
String input2 = "7^2";
String input3 = "4+3+3";
Thanks in advance

P.S. If more information required please ask, im desperate to get this done today :)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2008
Added on Jan 27 2008
26 comments
1,383 views