-1

Hi I am facing an issue while converting string value to integer. Actually I am converting String value into integer which contains special character String like:(20+30+20)/45*100 any solution?

  • You have to implement a parser to parse the expressions allowed, and then an evaluator which evaluates the expressions to generate a result. It's not trivial in any language. – Some programmer dude Dec 16 '19 at 12:38
  • can u please give an example actually i am doing this first time. – Aditiya Raj Dec 16 '19 at 12:45
  • First please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also please [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please read [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Dec 16 '19 at 13:04
  • And as mentioned this is not a trivial subject or suitable for beginners. You need to know your chosen language well, and you need to know many algorithms and data structures well too. – Some programmer dude Dec 16 '19 at 13:09
  • Thank you for your help i done this actually i was doing that type of expression first time but i have knowledge in android programming language of 3yrs so thanks for your help. – Aditiya Raj Dec 17 '19 at 04:44

1 Answers1

0

Try this:

var myNum= "(20+30+20)/45*100"
parseInt(myNum.replace(/\D/g,''));
Majdi Mohammad
  • 139
  • 1
  • 4