I am using DDMathParser
in my app, and have recently come across the need to get occurrences of any group of numbers within a () parentheses bracket thingy (very highly technical!). For example, I would need to get (6+5)
out of 6+7/8(6+5)
. Specifically, I would like to be able to do this so that I can make (56+9)sqrt
compile just as well as sqrt(56+9)
. Any help?
P.S. I know that the maker of DDMathParser is often sighted in this neck of the woods. I am secretly hoping that he will come to the rescue and either fix my problem so I can implement it myself or him make it part of DDMathParser! :)
So, I've thought a lot about this question since you posted it a month ago. From what I understand, you're constructing a string as the user clicks/taps buttons.
I think this is your problem.
As the user taps buttons, you should be constructing (or modifying) DDExpression
objects. This is the "pure" format of a math expression, whereas a string is lossy and difficult to manipulate. The string you show to the user should be generated from the DDExpression
tree you're building.
This is a complex problem, and I'm still not entirely sure how I would go about implementing this, but this is the root of how I'd do it. I would not just construct a string based on what the user types.