How can I make it so that here \\.(….|..) the points are only numbers [\\.(….|..)0-9]? (Java) Regex, matches?

have have the regex variable.matches("\.(....|..)"). Now my String needs to have a dot, and two or four characters after the dot. But my problem is, that I need that the characters are only Numbers from 0-9. For example I need that its only match when I have for instance:

.12 or .22 or .8389 or.3920 and not .dd or .d93j, so the characters after the dot needs to be numbers, but variable.matches("[\.(....|..)0-9]") dont work, how we could fix that?

>Solution :

Try this:


Leave a Reply