Java: check a String is Integer value with regular expression

__str.matches(“\\\d+”);__
d+ –> one or more digits
It allows starting with 0, eg. 0000124

__str.matches(“^[1-9]\\\d+”);__
It doesn’t allow starting with 0

Add a Comment