I have this String
String criteria="ESS.(BVA4+BVA5)+(-(DIESE.(BVM5+BVM6)))";
I want to put validations on it.
- It should only contain + – or . or all the three.
- It should not accept other symbols like !,% etc..
How to write regular expressions for that??
A lot of guesswork goes into this:
This returns
trueif the string only contains uppercase ASCII letters, ASCII digits, parentheses, plus/minus signs or dots. It includes the empty string (if you don’t want that, change the*into a+).Of course, it does nothing whatsoever to check whether (for example) the parentheses are balanced correctly (which you couldn’t do in a Java regex anyway).