This question already has an answer here:
- Validate IPv4 address in Java 18 answers
I want to define a String Pattern of the type A.B.C.D where the value of A,B,C and D should be in the range of 0 to 255. The length of A,B,C and D shall be from 1 to 3.
I now defined a pattern but if I test it with 256.255.255.255 it prints out true but It shall print out false because 256>255.
Here is my pattern:
class MyRegex{
String pattern = "\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}";
}
Aucun commentaire:
Enregistrer un commentaire