This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Evaluating an expression string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Evaluating an expression string " Watch "Evaluating an expression string " New topic
Author

Evaluating an expression string

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi all

In my application where in i have a string saying value = "2+3-4" . Is there any way given this string , i need the mathematical evaluation of the string inside i.e it should give me 1.

I feel the implementation for this will not be that easy , but is there any third party API which has this facility . Else can any one let me know how to go about this . The expression might include * and %

Let me know if there are any options
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

http://www.beanshell.org/
http://www.singularsys.com/jep/

Among others...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Evaluating an expression string
 
Similar Threads
Building object graphs of expressions written in template scripting languages
Struts2 annotation - validation for spaces to be allowed in name
How to replace a string in a HTML string
String replace
Need help with regexp