This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes String recognition questions... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "String recognition questions... " Watch "String recognition questions... " New topic

String recognition questions...

johny doe
Ranch Hand

Joined: Dec 07, 2007
Posts: 78

i want to build a function that inputs

a string
and i want to recognize a complex polynomial
in that string and if
for example if the user inputs the folloing string

(1+i)x^3 +(5i)x^2 +(3+5i)x +5

(each cell in the complex number array consists of
a real number and emaginary)
the function will put in cell 3 the value 1 in the real part
of cell 3 and 1 in the imaginary part of cell 3.

in cell 2
it will put 0 in the real part of cell 2
and 5 in the complex part of cell 2


is there a way for me to make this function??

another questiob
if i got
a string
for wich the user puts values for a and b
i want to make the following operation on the


how do i build a mechanism that recognises
this pattern??
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
There are a number of 3rd party libraries for parsing maths expressions. I've never used any, so can't recommend anything, but if you Google 'java math parser' you can take a look at a few and see if any meet your needs.

johny doe
Ranch Hand

Joined: Dec 07, 2007
Posts: 78
i coundnt find the thing iwas looking for
can you be more specific
Henry Wong

Joined: Sep 28, 2004
Posts: 20538

Originally posted by johny doe:
i coundnt find the thing iwas looking for
can you be more specific

I followed Joanne's instructions, and typed "java math parser" into google. But let me check.... Yup, the first hit claims that it supports complex numbers too.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
  • Developer Forums java string parsing
  • Parser (Java 2 Platform SE v1.4.2)
  • Lexical analysis and Java: Part 1 - Java World
  • A Simple Recursive Descent Parser

  • "The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
    I agree. Here's the link:
    subject: String recognition questions...
    It's not a secret anymore!