java - How to split string if splitting character is dynamic or unknown? -


i want make java program in want take string input. string have 2 integer numbers , operation performed. eg. 25+85 or 15*78

the output solution of string.

but don't know how split string because operator sign not known before execution.

you want check operation using using string.contains("+"); , checking other operators want support. split wherever operator is, string.split("+"). there parse output of string.split("+") using integer.parseint(string s) , return sum. pretty simple, luck.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -