Regex to check IP address in Java I'm toying with Regexes to parse IP Addresses.  I've got it to test for anything over 255:

public static boolean isIpAddress(String address)
{
    String regex = "^((25[0-5])|(((1[0-9]|2[0-4])|[1-9])?[0-9]))(\\.((25[0-5])|(((1[0-9]|2[0-4])|[1-9])?[0-9]))){3}$";
    try{
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(address);

        return m.find();
    }catch(Exception ex)
    {
        ex.printStackTrace();
    }
    return false;
}


Is there a more efficient way to write that regex? 

I understand that I could probably run something like this:

String[] addressChunks = address.split(".");
String regex = "^((25[0-5])|(((1[0-9]|2[0-4])|[1-9])?[0-9]))$";
Pattern p = Pattern.compile(regex);
for(String s: addressChunks)
{
    Matcher m = p.matcher(s);
    if(!m.find(s))
    {
      return false;
    }
}
return true;


But I'd rather keep it to one line of regex and compare it all instead of doing a split.
Try:

((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.|$)){4}