What you are looking for is called lexer. The lexer breaks the input into pieces (called tokens) that you can read.
Fortunately, your lexer is pretty simple and can be written by hand. For more complex lexers, you can use flex(as in Fast Lexicon Analyzer - not Adobe Flex), or (since you use Java) ANTLR (note: ANTLR is much more than just a lexer).
, , ( , , , , , . , ),
\d+
\+
-
*
/
\(
\)
: , . , . ( , , ).
:
List<String>input = new LinkedList<String>();
while(userInputString.length()>0){
for (final Pattern p : myRegexes){
final Matcher m = p.matcher(userInputString);
if(m.find()) {
input.add(m.group());
userInputString=userInputString.substring(m.group().length());
break;
}
}
}
: