I know how to check if a String is a positive double but how can I incorporate the function to check if the word is sell also?
This is what I use to check for positive double
sell2.matches("[+]?\\d*\\.?\\d+"))
EDIT: Answer in comment
I know how to check if a String is a positive double but how can I incorporate the function to check if the word is sell also?
This is what I use to check for positive double
sell2.matches("[+]?\\d*\\.?\\d+"))
EDIT: Answer in comment
private static final Pattern VALIDATOR = Pattern.compile("\\+?\\d+(\\.\\d+)?|all");
...
VALIDATOR.matcher(sell2).matches()
This is the regex you describe. Best have it compiled statically like this, otherwise calling sell2.matches(...)
compiles it every time, and that's a performance hit.