This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes manipulate strings with integers and operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "manipulate strings with integers and operators " Watch "manipulate strings with integers and operators " New topic

manipulate strings with integers and operators

ashleys smith

Joined: Sep 25, 2011
Posts: 1
I am building a calculator for doubles and one of the things I wanted to do was was take in negative numbers and exponents numbers . But I am having trouble doing that and I was wondering if someone could help me figure it out I set up a pattern from the E and e. The user input can look like that as a String = "-(a1+-a2)*10E-10" and it can also look like this "(-a1+-a2)*10E3" anyone know how I can make it look like this " ( -a1 + -a2 ) * 10000 " so I can apply the split method and parse it to the stacks =)
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the javaranch,

You could search for the E followed by a number and replace what with the corresponding value.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
I agree. Here's the link:
subject: manipulate strings with integers and operators
jQuery in Action, 3rd edition