first of all I will give ... expression like
4/12 - 3/9
or I can give
4/12 + 3/9
so I don't know how to split i.e., split using + or -
split("[+]") or split("[-]");
Main Topics
Browse All TopicsI need to get tokens separetly...for expression...
4/12 - 2/8
I need 4 separetly / separetly - separetly .... how to do it..
next time i may have
4/12 * 8/2
or 4/12 + 8/2
I can do this if I am able to divide each one as separate token..
let me know how to do it..
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I have an idea....
but let me know how to do it...
in each expression...
a space is there after each fraction...
so split using space
index = split(" "); // is this correct
fraction1 = str.substring(0, index+1)
operator = str.substring(index+1, index+2);
fraction2 = str.substring(index+2, str.length);
but it went wrong some where...
You'd be better off using an expression parser:
http://sourceforge.net/pro
check this one....
I am getting error as
"cannot find symbol "
symbol : strl
Scanner s = new Scanner(System.in);
String str1=s.nextLine();
String[] tokens = strl.split("[+,-]");
String[] fraction1 = tokens[0].split("/");
String num1 = fraction1[0];
String deno1 = fraction1[1];
System.out.println( "Numerator is:" + num1) ;
System.out.println( "Denominator is:" +deno1);
Business Accounts
Answer for Membership
by: objectsPosted on 2009-11-04 at 12:46:24ID: 25743712
you can use split(), eg.
String[] tokens = s.split("[/ ]");