I need regex expression for the following :
\d{0,8}(\.\d{1,2})?$
this works for the above case , but I don't want the following strings to be accepted. The string should not result to zero.
Another option is to assert not only dots and zeroes
^(?![0.]*$)\d{0,8}(?:\.\d{1,2})?$
In Java
String regex = "^(?![0.]*$)\\d{0,8}(?:\\.\\d{1,2})?$";
If you want a match only, you can omit the capturing group and make it non capturing (?: