i wrote a regular expression to match a string to be in range 0-255.
my regular expression is ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
i know my regular expression is technically incorrect as it will be true after matching the first character of the string matches [0-9] so even "1234" will be matched .
now i write it in python..
a="2514"
>>> if(re.match("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",a)):
... print("yes")
output = yes
but when i write it in java ..
String s="2514";
if(s.matches("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"))
{
System.out.println("yes");
}
output is nothing