The [a-b] range thing is for ranges of characters, not ranges of numbers. To do this in regex it would be something like this. (Note, this is not complete or correct, it just gives you the idea of what you'd have to do.)
"127((\\.((0)|(\\d{2})|(1(\\d{2}))|(2[0-4]\\d)|(25[0-5))){3}"
Basically it's "zero OR (any 2-digit number) OR (1 followed by any 2 digits) OR (2 followed by 0-4 followed by any digit) OR (2 followed by 5 followed by 0-5)" -- the whole thing repeated 3 times.
That's just off the top of my head. You'll have to work out the kinks if you want to use it.
Personally, I wouldn't use regex for this. I'd construct a java.net.InetAddres and then see if the first part is "127". That seems simpler to write, simpler to read, and a more direct expression of your intent.
I totally forgot one-digit numbers. Don't know what I was thinking with "zero OR 2-digits..." Should have just been "any one digit or 2-digit number" which would be \\d{1,2}, and then special handling for the 3-digit numbers.
But then, like I said, I probably wouldn't use regex for this anyway. :-)
Ok, Thank you.
I get a way to do it.
public static void main(String[] args)
{
String ip = "127.0.0.0";
String[] d = ip.split("\\.");
if(ip.matches("127.\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}") && Integer.parseInt(d[1]) <=255 && Integer.parseInt(d[2]) <=255 && Integer.parseInt(d[3]) <= 255)
}