I have a question how can I (easily) parse String like that: String sZ = "20i + 5.4";
On page http://commons.apache.org/math/userguide/complex.html I found example: ComplexFormat cf = new ComplexFormat(); Complex c = cf.parse("1.110 + 2.222i"); It's ok, but if I have inverted form like "20i + 5.4" then there is exception: "org.apache.commons.math.MathRuntimeException$9: unparseable complex number: "20i + 5.4". Pseudo-algorithm for proposed solution: 1) Parse first number 2) IF first number has imaginary character THEN remember that second number should be real number (without imaginary character) 3) Parse second number 4) IF second number has imaginary character and first had it too (look at 2)), THEN throw exception Thanks ! Greg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
